@p100-web/core-three 100.1.1 → 100.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +41 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +171 -0
- package/dist/App.js.map +1 -0
- package/dist/ComponentFactory.d.ts +5 -0
- package/dist/ComponentFactory.d.ts.map +1 -0
- package/dist/ComponentFactory.js +13 -0
- package/dist/ComponentFactory.js.map +1 -0
- package/dist/ThreeCanvas.d.ts +56 -0
- package/dist/ThreeCanvas.d.ts.map +1 -0
- package/dist/ThreeCanvas.js +418 -0
- package/dist/ThreeCanvas.js.map +1 -0
- package/dist/ThreeEngine.d.ts +24 -0
- package/dist/ThreeEngine.d.ts.map +1 -0
- package/dist/ThreeEngine.js +102 -0
- package/dist/ThreeEngine.js.map +1 -0
- package/dist/ThreeNodeRenderer.d.ts +42 -0
- package/dist/ThreeNodeRenderer.d.ts.map +1 -0
- package/dist/ThreeNodeRenderer.js +119 -0
- package/dist/ThreeNodeRenderer.js.map +1 -0
- package/dist/animations/ModelAnimation.d.ts +21 -0
- package/dist/animations/ModelAnimation.d.ts.map +1 -0
- package/dist/animations/ModelAnimation.js +45 -0
- package/dist/animations/ModelAnimation.js.map +1 -0
- package/dist/assets/ThreeAssetLoader.d.ts +98 -0
- package/dist/assets/ThreeAssetLoader.d.ts.map +1 -0
- package/dist/assets/ThreeAssetLoader.js +495 -0
- package/dist/assets/ThreeAssetLoader.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/pcomponents/PAnimator.d.ts +24 -0
- package/dist/pcomponents/PAnimator.d.ts.map +1 -0
- package/dist/pcomponents/PAnimator.js +133 -0
- package/dist/pcomponents/PAnimator.js.map +1 -0
- package/dist/pcomponents/PBackground.d.ts +15 -0
- package/dist/pcomponents/PBackground.d.ts.map +1 -0
- package/dist/pcomponents/PBackground.js +104 -0
- package/dist/pcomponents/PBackground.js.map +1 -0
- package/dist/pcomponents/PBasicMaterial.d.ts +20 -0
- package/dist/pcomponents/PBasicMaterial.d.ts.map +1 -0
- package/dist/pcomponents/PBasicMaterial.js +161 -0
- package/dist/pcomponents/PBasicMaterial.js.map +1 -0
- package/dist/pcomponents/PCollider.d.ts +18 -0
- package/dist/pcomponents/PCollider.d.ts.map +1 -0
- package/dist/pcomponents/PCollider.js +59 -0
- package/dist/pcomponents/PCollider.js.map +1 -0
- package/dist/pcomponents/PCubeGeometry.d.ts +8 -0
- package/dist/pcomponents/PCubeGeometry.d.ts.map +1 -0
- package/dist/pcomponents/PCubeGeometry.js +23 -0
- package/dist/pcomponents/PCubeGeometry.js.map +1 -0
- package/dist/pcomponents/PEnvironment.d.ts +12 -0
- package/dist/pcomponents/PEnvironment.d.ts.map +1 -0
- package/dist/pcomponents/PEnvironment.js +39 -0
- package/dist/pcomponents/PEnvironment.js.map +1 -0
- package/dist/pcomponents/PImageCache.d.ts +11 -0
- package/dist/pcomponents/PImageCache.d.ts.map +1 -0
- package/dist/pcomponents/PImageCache.js +35 -0
- package/dist/pcomponents/PImageCache.js.map +1 -0
- package/dist/pcomponents/PLight.d.ts +8 -0
- package/dist/pcomponents/PLight.d.ts.map +1 -0
- package/dist/pcomponents/PLight.js +45 -0
- package/dist/pcomponents/PLight.js.map +1 -0
- package/dist/pcomponents/PLightDirectional.d.ts +8 -0
- package/dist/pcomponents/PLightDirectional.d.ts.map +1 -0
- package/dist/pcomponents/PLightDirectional.js +36 -0
- package/dist/pcomponents/PLightDirectional.js.map +1 -0
- package/dist/pcomponents/PMaskedMaterial.d.ts +17 -0
- package/dist/pcomponents/PMaskedMaterial.d.ts.map +1 -0
- package/dist/pcomponents/PMaskedMaterial.js +195 -0
- package/dist/pcomponents/PMaskedMaterial.js.map +1 -0
- package/dist/pcomponents/PMaterialModifier.d.ts +8 -0
- package/dist/pcomponents/PMaterialModifier.d.ts.map +1 -0
- package/dist/pcomponents/PMaterialModifier.js +22 -0
- package/dist/pcomponents/PMaterialModifier.js.map +1 -0
- package/dist/pcomponents/PModelAnnotation.d.ts +11 -0
- package/dist/pcomponents/PModelAnnotation.d.ts.map +1 -0
- package/dist/pcomponents/PModelAnnotation.js +21 -0
- package/dist/pcomponents/PModelAnnotation.js.map +1 -0
- package/dist/pcomponents/PModelAnnotations.d.ts +10 -0
- package/dist/pcomponents/PModelAnnotations.d.ts.map +1 -0
- package/dist/pcomponents/PModelAnnotations.js +25 -0
- package/dist/pcomponents/PModelAnnotations.js.map +1 -0
- package/dist/pcomponents/PModelGLTF.d.ts +15 -0
- package/dist/pcomponents/PModelGLTF.d.ts.map +1 -0
- package/dist/pcomponents/PModelGLTF.js +111 -0
- package/dist/pcomponents/PModelGLTF.js.map +1 -0
- package/dist/pcomponents/PModelNode.d.ts +13 -0
- package/dist/pcomponents/PModelNode.d.ts.map +1 -0
- package/dist/pcomponents/PModelNode.js +71 -0
- package/dist/pcomponents/PModelNode.js.map +1 -0
- package/dist/pcomponents/PPhysicalMaterial.d.ts +13 -0
- package/dist/pcomponents/PPhysicalMaterial.d.ts.map +1 -0
- package/dist/pcomponents/PPhysicalMaterial.js +100 -0
- package/dist/pcomponents/PPhysicalMaterial.js.map +1 -0
- package/dist/pcomponents/PPlaneGeometry.d.ts +8 -0
- package/dist/pcomponents/PPlaneGeometry.d.ts.map +1 -0
- package/dist/pcomponents/PPlaneGeometry.js +23 -0
- package/dist/pcomponents/PPlaneGeometry.js.map +1 -0
- package/dist/pcomponents/PProjectRoot.d.ts +8 -0
- package/dist/pcomponents/PProjectRoot.d.ts.map +1 -0
- package/dist/pcomponents/PProjectRoot.js +24 -0
- package/dist/pcomponents/PProjectRoot.js.map +1 -0
- package/dist/pcomponents/PSlider.d.ts +18 -0
- package/dist/pcomponents/PSlider.d.ts.map +1 -0
- package/dist/pcomponents/PSlider.js +62 -0
- package/dist/pcomponents/PSlider.js.map +1 -0
- package/dist/pcomponents/PSound.d.ts +17 -0
- package/dist/pcomponents/PSound.d.ts.map +1 -0
- package/dist/pcomponents/PSound.js +119 -0
- package/dist/pcomponents/PSound.js.map +1 -0
- package/dist/pcomponents/PSphereGeometry.d.ts +9 -0
- package/dist/pcomponents/PSphereGeometry.d.ts.map +1 -0
- package/dist/pcomponents/PSphereGeometry.js +24 -0
- package/dist/pcomponents/PSphereGeometry.js.map +1 -0
- package/dist/pcomponents/PSprite.d.ts +13 -0
- package/dist/pcomponents/PSprite.d.ts.map +1 -0
- package/dist/pcomponents/PSprite.js +73 -0
- package/dist/pcomponents/PSprite.js.map +1 -0
- package/dist/pcomponents/PSpriteSheet.d.ts +13 -0
- package/dist/pcomponents/PSpriteSheet.d.ts.map +1 -0
- package/dist/pcomponents/PSpriteSheet.js +49 -0
- package/dist/pcomponents/PSpriteSheet.js.map +1 -0
- package/dist/pcomponents/PText.d.ts +10 -0
- package/dist/pcomponents/PText.d.ts.map +1 -0
- package/dist/pcomponents/PText.js +44 -0
- package/dist/pcomponents/PText.js.map +1 -0
- package/dist/pcomponents/PVideoPlayer.d.ts +5 -0
- package/dist/pcomponents/PVideoPlayer.d.ts.map +1 -0
- package/dist/pcomponents/PVideoPlayer.js +12 -0
- package/dist/pcomponents/PVideoPlayer.js.map +1 -0
- package/dist/pcomponents.d.ts +27 -0
- package/dist/pcomponents.d.ts.map +1 -0
- package/dist/pcomponents.js +33 -0
- package/dist/pcomponents.js.map +1 -0
- package/dist/postprocessing/PSSRPass.d.ts +19 -0
- package/dist/postprocessing/PSSRPass.d.ts.map +1 -0
- package/dist/postprocessing/PSSRPass.js +69 -0
- package/dist/postprocessing/PSSRPass.js.map +1 -0
- package/dist/postprocessing/ThreeJsPostProcessor.d.ts +32 -0
- package/dist/postprocessing/ThreeJsPostProcessor.d.ts.map +1 -0
- package/dist/postprocessing/ThreeJsPostProcessor.js +264 -0
- package/dist/postprocessing/ThreeJsPostProcessor.js.map +1 -0
- package/dist/three/ColliderObject3D.d.ts +19 -0
- package/dist/three/ColliderObject3D.d.ts.map +1 -0
- package/dist/three/ColliderObject3D.js +96 -0
- package/dist/three/ColliderObject3D.js.map +1 -0
- package/dist/three/FreeCameraControls.d.ts +32 -0
- package/dist/three/FreeCameraControls.d.ts.map +1 -0
- package/dist/three/FreeCameraControls.js +173 -0
- package/dist/three/FreeCameraControls.js.map +1 -0
- package/dist/three/OrbitCameraControls.d.ts +32 -0
- package/dist/three/OrbitCameraControls.d.ts.map +1 -0
- package/dist/three/OrbitCameraControls.js +247 -0
- package/dist/three/OrbitCameraControls.js.map +1 -0
- package/dist/three/VrCameraControls.d.ts +30 -0
- package/dist/three/VrCameraControls.d.ts.map +1 -0
- package/dist/three/VrCameraControls.js +140 -0
- package/dist/three/VrCameraControls.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { NodeEvents, PAnimator as PAnimatorBase, } from "@p100-web/core";
|
|
2
|
+
export default class PAnimator extends PAnimatorBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this._animation = null;
|
|
6
|
+
this._playedDuration = 0;
|
|
7
|
+
this._segmentDuration = 0;
|
|
8
|
+
this._playing = false;
|
|
9
|
+
//
|
|
10
|
+
// INodeEventListener
|
|
11
|
+
//
|
|
12
|
+
this.onNodeEvent = (component, type, model) => {
|
|
13
|
+
if (!(type & NodeEvents.ModelLoaded))
|
|
14
|
+
return;
|
|
15
|
+
this._animation = null;
|
|
16
|
+
this.loaded = false;
|
|
17
|
+
this.validAnimation = false;
|
|
18
|
+
// We are updating the model
|
|
19
|
+
if (component !== null && model !== null) {
|
|
20
|
+
this._animation = component.getAnimation(this.clip);
|
|
21
|
+
this.validAnimation = this._animation !== null;
|
|
22
|
+
this.loaded = true;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
this.onFinished = () => {
|
|
26
|
+
this._playedDuration = 0;
|
|
27
|
+
this._stop();
|
|
28
|
+
this.outevent_onFinished?.emit(null, this);
|
|
29
|
+
};
|
|
30
|
+
this.updateSegment = (dt) => {
|
|
31
|
+
this._playedDuration += dt;
|
|
32
|
+
if (this._playedDuration >= this._segmentDuration) {
|
|
33
|
+
if (this.loop) {
|
|
34
|
+
this._playedDuration = 0;
|
|
35
|
+
this._animation.setTime(this.from);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this._animation.setTime(this.to);
|
|
39
|
+
this._animation?.setPaused(true);
|
|
40
|
+
this.onFinished();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this._animation?.update(dt);
|
|
45
|
+
};
|
|
46
|
+
this.update = (dt) => {
|
|
47
|
+
this._animation.update(dt);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
getModelComponent() {
|
|
51
|
+
return this.findComponent("PModelGLTF");
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
// Find model
|
|
55
|
+
const model = this.getModelComponent();
|
|
56
|
+
if (model === null) {
|
|
57
|
+
this.context.error("Animator did not find model");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
model.node.addNodeEventListener(this);
|
|
61
|
+
}
|
|
62
|
+
unrender() {
|
|
63
|
+
if (this._playing) {
|
|
64
|
+
this._stop();
|
|
65
|
+
}
|
|
66
|
+
this._animation = null;
|
|
67
|
+
const model = this.getModelComponent();
|
|
68
|
+
model?.node.removeNodeEventListener(this);
|
|
69
|
+
this.loaded = false;
|
|
70
|
+
this.validAnimation = false;
|
|
71
|
+
}
|
|
72
|
+
getAnimationClips() {
|
|
73
|
+
const model = this.getModelComponent();
|
|
74
|
+
return model?.getAnimationNames() || [];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Stop playback and remove event listeners
|
|
78
|
+
*/
|
|
79
|
+
_stop() {
|
|
80
|
+
if (this._animation?.isRunning()) {
|
|
81
|
+
this._animation.stop();
|
|
82
|
+
}
|
|
83
|
+
if (this.segment) {
|
|
84
|
+
this.context.getCanvas()?.unregisterUpdate(this.updateSegment);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.context.getCanvas()?.unregisterUpdate(this.update);
|
|
88
|
+
this._animation?.removeFinishedListener(this.onFinished);
|
|
89
|
+
}
|
|
90
|
+
this._playing = false;
|
|
91
|
+
// Always call on stop
|
|
92
|
+
this.outevent_onStopped?.emit(null, this);
|
|
93
|
+
}
|
|
94
|
+
callback_onPlay() {
|
|
95
|
+
if (this.clip === "")
|
|
96
|
+
return;
|
|
97
|
+
if (this._playing) {
|
|
98
|
+
this._stop();
|
|
99
|
+
}
|
|
100
|
+
if (this._animation !== null) {
|
|
101
|
+
if (this._animation.isRunning()) {
|
|
102
|
+
this.context.error("Animation was already running");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this._playedDuration = 0;
|
|
106
|
+
this._segmentDuration = this.to - this.from;
|
|
107
|
+
this._animation.setLoop(this.loop);
|
|
108
|
+
if (this.segment) {
|
|
109
|
+
this._animation.setPaused(false);
|
|
110
|
+
this._animation.setTime(this.from);
|
|
111
|
+
this.context.getCanvas().registerUpdate(this.updateSegment);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this._animation.setTime(0);
|
|
115
|
+
this._animation.addFinishedListener(this.onFinished);
|
|
116
|
+
this.context.getCanvas().registerUpdate(this.update);
|
|
117
|
+
}
|
|
118
|
+
this._playing = true;
|
|
119
|
+
this._animation.play();
|
|
120
|
+
this.outevent_onPlay?.emit("", this);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.context.error("Animation not found: " + this.clip);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
callback_onStop() {
|
|
127
|
+
if (this.clip === "")
|
|
128
|
+
return;
|
|
129
|
+
this._playedDuration = 0;
|
|
130
|
+
this._stop();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=PAnimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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CAAC;IACf,CAAC;CAqBF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MeshBasicMaterial, SphereGeometry, Texture } from "three";
|
|
2
|
+
import { PBackground as PBackgroundBase } from "@p100-web/core";
|
|
3
|
+
import { TextureTask, VideoTextureTask, ITextureTaskLoader, IVideoTextureTaskLoader } from "../assets/ThreeAssetLoader";
|
|
4
|
+
export default class PBackground extends PBackgroundBase implements ITextureTaskLoader, IVideoTextureTaskLoader {
|
|
5
|
+
protected _material: MeshBasicMaterial | null;
|
|
6
|
+
protected _geometry: SphereGeometry | null;
|
|
7
|
+
protected _texture: Texture | null;
|
|
8
|
+
_dispose(unrender: boolean): void;
|
|
9
|
+
getTexture<T>(): T | null;
|
|
10
|
+
unrender(): void;
|
|
11
|
+
render(): void;
|
|
12
|
+
onVideoTextureTaskLoaded: (task: VideoTextureTask) => void;
|
|
13
|
+
onTextureTaskLoaded: (task: TextureTask) => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=PBackground.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PBackground.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PBackground.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EACjB,cAAc,EACd,OAAO,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,WAAW,IAAI,eAAe,EAC/B,MAAM,gBAAgB,CAAC;AAExB,OAAyB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,WACnB,SAAQ,eACR,YAAW,kBAAkB,EAAE,uBAAuB;IAEtD,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IACrD,SAAS,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAQ;IAClD,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAQ;IAE1C,QAAQ,CAAC,QAAQ,EAAE,OAAO;IAuB1B,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;IAIzB,QAAQ;IAIR,MAAM;IA6CN,wBAAwB,GAAI,MAAM,gBAAgB,KAAG,IAAI,CAcvD;IAMF,mBAAmB,GAAI,MAAM,WAAW,KAAG,IAAI,CAc7C;CACH"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BackSide, MathUtils, Mesh, MeshBasicMaterial, SphereGeometry, } from "three";
|
|
2
|
+
import { FileType, PBackground as PBackgroundBase, } from "@p100-web/core";
|
|
3
|
+
export default class PBackground extends PBackgroundBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this._material = null;
|
|
7
|
+
this._geometry = null;
|
|
8
|
+
this._texture = null;
|
|
9
|
+
//
|
|
10
|
+
// VideoTextureTask
|
|
11
|
+
//
|
|
12
|
+
this.onVideoTextureTaskLoaded = (task) => {
|
|
13
|
+
if (this._material === null) {
|
|
14
|
+
this.context.error("onVideoTextureLoaded and material was null");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (task.texture === null) {
|
|
18
|
+
this.context.error("onVideoTextureLoaded and texture was null");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const texture = task.texture;
|
|
22
|
+
this._material.map = texture;
|
|
23
|
+
this._material.needsUpdate = true;
|
|
24
|
+
this._texture = texture;
|
|
25
|
+
};
|
|
26
|
+
//
|
|
27
|
+
// TextureTask
|
|
28
|
+
//
|
|
29
|
+
this.onTextureTaskLoaded = (task) => {
|
|
30
|
+
if (this._material === null) {
|
|
31
|
+
this.context.error("onTextureLoaded and material was null");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (task.texture === null) {
|
|
35
|
+
this.context.error("onTextureLoaded and texture was null");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const texture = task.texture;
|
|
39
|
+
this._material.map = texture;
|
|
40
|
+
this._material.needsUpdate = true;
|
|
41
|
+
this._texture = texture;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
_dispose(unrender) {
|
|
45
|
+
// AssetLoader will take care of cleaning up the html elements
|
|
46
|
+
this._texture?.dispose();
|
|
47
|
+
this._texture = null;
|
|
48
|
+
// Check if we should dispose Material
|
|
49
|
+
if (this._material) {
|
|
50
|
+
this._material.map = null;
|
|
51
|
+
this._material.needsUpdate = true;
|
|
52
|
+
// Dispose material
|
|
53
|
+
if (unrender) {
|
|
54
|
+
this._material.dispose();
|
|
55
|
+
this._material = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (unrender && this._geometry !== null) {
|
|
59
|
+
this._geometry.dispose();
|
|
60
|
+
this._geometry = null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getTexture() {
|
|
64
|
+
return this._texture;
|
|
65
|
+
}
|
|
66
|
+
unrender() {
|
|
67
|
+
this._dispose(true);
|
|
68
|
+
}
|
|
69
|
+
render() {
|
|
70
|
+
const geometry = new SphereGeometry(this.radius, 32, 32);
|
|
71
|
+
this._geometry = geometry;
|
|
72
|
+
const mesh = new Mesh(geometry);
|
|
73
|
+
mesh.castShadow = false;
|
|
74
|
+
mesh.receiveShadow = false;
|
|
75
|
+
this.node.set_el(mesh);
|
|
76
|
+
mesh.rotation.y = MathUtils.degToRad(this.rotation);
|
|
77
|
+
const material = new MeshBasicMaterial({
|
|
78
|
+
color: 0xffffff,
|
|
79
|
+
map: null,
|
|
80
|
+
side: BackSide,
|
|
81
|
+
transparent: false,
|
|
82
|
+
fog: false,
|
|
83
|
+
// shadowSide: DoubleSide,
|
|
84
|
+
depthTest: true, // ?? maybe
|
|
85
|
+
depthWrite: true,
|
|
86
|
+
});
|
|
87
|
+
this._material = material;
|
|
88
|
+
mesh.material = material;
|
|
89
|
+
mesh.scale.x = mesh.scale.x * -1;
|
|
90
|
+
if (this.file_texture !== null) {
|
|
91
|
+
if (this.file_texture.type === FileType.Image) {
|
|
92
|
+
this.context
|
|
93
|
+
.assetLoader()
|
|
94
|
+
.addTextureTask(this, this.file_texture);
|
|
95
|
+
}
|
|
96
|
+
else if (this.file_texture.type === FileType.Video) {
|
|
97
|
+
this.context
|
|
98
|
+
.assetLoader()
|
|
99
|
+
.addVideoTextureTask(this, this.file_texture);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=PBackground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PBackground.js","sourceRoot":"","sources":["../../src/pcomponents/PBackground.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,iBAAiB,EACjB,cAAc,GAEf,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,QAAQ,EACR,WAAW,IAAI,eAAe,GAC/B,MAAM,gBAAgB,CAAC;AASxB,MAAM,CAAC,OAAO,OAAO,WACnB,SAAQ,eAAe;IADzB;;QAIY,cAAS,GAA6B,IAAI,CAAC;QAC3C,cAAS,GAA0B,IAAI,CAAC;QACxC,aAAQ,GAAmB,IAAI,CAAC;QA0E1C,EAAE;QACF,oBAAoB;QACpB,EAAE;QAEF,6BAAwB,GAAG,CAAC,IAAsB,EAAQ,EAAE;YAC1D,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;gBAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;gBACjE,OAAO;YACT,CAAC;YACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC1B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;gBAChE,OAAO;YACT,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC;YAC7B,IAAI,CAAC,SA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AC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAC9C,IAAI,CAAC,OAAO;qBACT,WAAW,EAAoB;qBAC/B,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7C,CAAC;iBAAM,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACrD,IAAI,CAAC,OAAO;qBACT,WAAW,EAAoB;qBAC/B,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;CAyCF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MeshBasicMaterial, Texture } from "three";
|
|
2
|
+
import { INodeEventListener, INodeEventSender, PBasicMaterial as PBasicMaterialBase } from "@p100-web/core";
|
|
3
|
+
import { TextureTask, VideoTextureTask, ITextureTaskLoader, IVideoTextureTaskLoader } from "../assets/ThreeAssetLoader";
|
|
4
|
+
export default class PBasicMaterial extends PBasicMaterialBase implements ITextureTaskLoader, IVideoTextureTaskLoader, INodeEventSender {
|
|
5
|
+
protected _material: MeshBasicMaterial | null;
|
|
6
|
+
protected _texture: Texture | null;
|
|
7
|
+
getTexture<T>(): T | null;
|
|
8
|
+
_dispose(unrender: boolean): void;
|
|
9
|
+
unrender(): void;
|
|
10
|
+
render(): void;
|
|
11
|
+
onAddNodeEventListener: (listener: INodeEventListener) => void;
|
|
12
|
+
callback_setOpacity(payloadValue: string | null): void;
|
|
13
|
+
onVideoTextureTaskLoaded: (task: VideoTextureTask) => void;
|
|
14
|
+
onTextureTaskLoaded: (task: TextureTask) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called by this component.
|
|
17
|
+
*/
|
|
18
|
+
setTextureRepeat(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=PBasicMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PBasicMaterial.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PBasicMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAEjB,OAAO,EAER,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAEhB,cAAc,IAAI,kBAAkB,EACrC,MAAM,gBAAgB,CAAC;AAIxB,OAAyB,EACvB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,cACnB,SAAQ,kBACR,YAAW,kBAAkB,EAAE,uBAAuB,EAAE,gBAAgB;IAExE,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IACrD,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAQ;IAE1C,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;IAQzB,QAAQ,CAAC,QAAQ,EAAE,OAAO;IAqB1B,QAAQ;IAMR,MAAM;IAoDN,sBAAsB,GAAI,UAAU,kBAAkB,UAgBpD;IAMF,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAWtD,wBAAwB,GAAI,MAAM,gBAAgB,KAAG,IAAI,CAmBvD;IAMF,mBAAmB,GAAI,MAAM,WAAW,KAAG,IAAI,CAmB7C;IAMF;;OAEG;IACH,gBAAgB;CAajB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { BackSide, ClampToEdgeWrapping, FrontSide, MeshBasicMaterial, RepeatWrapping, Vector2, } from "three";
|
|
2
|
+
import { NodeEvents, PBasicMaterial as PBasicMaterialBase, } from "@p100-web/core";
|
|
3
|
+
import { FileSubType, FileType } from "@p100-web/core";
|
|
4
|
+
export default class PBasicMaterial extends PBasicMaterialBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this._material = null;
|
|
8
|
+
this._texture = null;
|
|
9
|
+
//
|
|
10
|
+
// INodeEventSender
|
|
11
|
+
//
|
|
12
|
+
this.onAddNodeEventListener = (listener) => {
|
|
13
|
+
if (this.file_texture !== null && this._texture) {
|
|
14
|
+
if (this.file_texture.type === FileType.Image) {
|
|
15
|
+
listener.onNodeEvent(this, NodeEvents.ImageTextureLoaded, this._texture);
|
|
16
|
+
}
|
|
17
|
+
else if (this.file_texture.type === FileType.Video) {
|
|
18
|
+
listener.onNodeEvent(this, NodeEvents.VideoTextureLoaded, this._texture);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//
|
|
23
|
+
// VideoTextureTask
|
|
24
|
+
//
|
|
25
|
+
this.onVideoTextureTaskLoaded = (task) => {
|
|
26
|
+
if (this._material === null) {
|
|
27
|
+
this.context.error("onVideoTextureLoaded and material was null");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (task.texture === null) {
|
|
31
|
+
this.context.error("onVideoTextureLoaded and texture was null");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this._texture = task.texture;
|
|
35
|
+
const texture = task.texture;
|
|
36
|
+
this._material.map = texture;
|
|
37
|
+
this._material.needsUpdate = true;
|
|
38
|
+
this.setTextureRepeat();
|
|
39
|
+
// Notify other components
|
|
40
|
+
this.node.emitNodeEvent(this, NodeEvents.VideoTextureLoaded, texture);
|
|
41
|
+
};
|
|
42
|
+
//
|
|
43
|
+
// TextureTask
|
|
44
|
+
//
|
|
45
|
+
this.onTextureTaskLoaded = (task) => {
|
|
46
|
+
if (this._material === null) {
|
|
47
|
+
this.context.error("onTextureLoaded and material was null");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (task.texture === null) {
|
|
51
|
+
this.context.error("onTextureLoaded and texture was null");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this._texture = task.texture;
|
|
55
|
+
const texture = task.texture;
|
|
56
|
+
this._material.map = texture;
|
|
57
|
+
this._material.needsUpdate = true;
|
|
58
|
+
this.setTextureRepeat();
|
|
59
|
+
// Notify other components
|
|
60
|
+
this.node.emitNodeEvent(this, NodeEvents.ImageTextureLoaded, texture);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
getTexture() {
|
|
64
|
+
return this._texture;
|
|
65
|
+
}
|
|
66
|
+
//
|
|
67
|
+
// PComponent
|
|
68
|
+
//
|
|
69
|
+
_dispose(unrender) {
|
|
70
|
+
if (this._texture !== null) {
|
|
71
|
+
// AssetLoader will take care of cleaning up the html elements
|
|
72
|
+
this._texture.dispose();
|
|
73
|
+
this._texture = null;
|
|
74
|
+
}
|
|
75
|
+
// Check if we should dispose Material
|
|
76
|
+
if (this._material) {
|
|
77
|
+
// Do we have a texture as well?
|
|
78
|
+
this._material.map = null;
|
|
79
|
+
this._material.needsUpdate = true;
|
|
80
|
+
// Dispose material
|
|
81
|
+
if (unrender) {
|
|
82
|
+
this._material.dispose();
|
|
83
|
+
this._material = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
unrender() {
|
|
88
|
+
this.node.unregisterNodeEventSender(this);
|
|
89
|
+
this._dispose(true);
|
|
90
|
+
}
|
|
91
|
+
render() {
|
|
92
|
+
this.node.registerNodeEventSender(this);
|
|
93
|
+
if (!this.node.hasEl()) {
|
|
94
|
+
this.context.error("Material is missing Mesh");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let inverted = this.inverted;
|
|
98
|
+
if (this.context.isInverted()) {
|
|
99
|
+
inverted = !inverted;
|
|
100
|
+
}
|
|
101
|
+
const material = new MeshBasicMaterial({
|
|
102
|
+
color: this.color,
|
|
103
|
+
map: null,
|
|
104
|
+
side: inverted ? BackSide : FrontSide,
|
|
105
|
+
opacity: this.opacity,
|
|
106
|
+
transparent: this.transparent,
|
|
107
|
+
fog: false,
|
|
108
|
+
// shadowSide: DoubleSide,
|
|
109
|
+
wireframe: false,
|
|
110
|
+
alphaTest: this.alphaTest,
|
|
111
|
+
depthWrite: this.depthWrite,
|
|
112
|
+
});
|
|
113
|
+
this._material = material;
|
|
114
|
+
const mesh = this.node.getEl();
|
|
115
|
+
mesh.material = material;
|
|
116
|
+
mesh.renderOrder = this.renderOrder;
|
|
117
|
+
if (this.file_texture !== null) {
|
|
118
|
+
// Check which loader to use
|
|
119
|
+
if (this.file_texture.type === FileType.Image) {
|
|
120
|
+
this.context
|
|
121
|
+
.assetLoader()
|
|
122
|
+
.addTextureTask(this, this.file_texture);
|
|
123
|
+
}
|
|
124
|
+
else if (this.file_texture.type === FileType.Video) {
|
|
125
|
+
this.context
|
|
126
|
+
.assetLoader()
|
|
127
|
+
.addVideoTextureTask(this, this.file_texture);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
material.needsUpdate = true;
|
|
131
|
+
}
|
|
132
|
+
//
|
|
133
|
+
// Event Callbacks
|
|
134
|
+
//
|
|
135
|
+
callback_setOpacity(payloadValue) {
|
|
136
|
+
if (this._material && payloadValue) {
|
|
137
|
+
const opacity = parseFloat(payloadValue);
|
|
138
|
+
this._material.opacity = opacity;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//
|
|
142
|
+
// Tools
|
|
143
|
+
//
|
|
144
|
+
/**
|
|
145
|
+
* Called by this component.
|
|
146
|
+
*/
|
|
147
|
+
setTextureRepeat() {
|
|
148
|
+
const texture = this._texture;
|
|
149
|
+
if (texture !== null) {
|
|
150
|
+
texture.wrapS = this.repeat.x > 1 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
151
|
+
texture.wrapT = this.repeat.y > 1 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
152
|
+
const repeatY = this.file_texture.subType === FileSubType.Stereo ? 0.5 : 1;
|
|
153
|
+
texture.repeat = new Vector2(this.repeat.x, this.repeat.y * repeatY);
|
|
154
|
+
texture.offset = new Vector2(this.offset.x, this.offset.y);
|
|
155
|
+
if (this._material)
|
|
156
|
+
this._material.needsUpdate = true;
|
|
157
|
+
texture.needsUpdate = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=PBasicMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PBasicMaterial.js","sourceRoot":"","sources":["../../src/pcomponents/PBasicMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,SAAS,EAET,iBAAiB,EACjB,cAAc,EAEd,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,UAAU,EACV,cAAc,IAAI,kBAAkB,GACrC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AASvD,MAAM,CAAC,OAAO,OAAO,cACnB,SAAQ,kBAAkB;IAD5B;;QAIY,cAAS,GAA6B,IAAI,CAAC;QAC3C,aAAQ,GAAmB,IAAI,CAAC;QAqF1C,EAAE;QACF,oBAAoB;QACpB,EAAE;QAEF,2BAAsB,GAAG,CAAC,QAA4B,EAAE,EAAE;YACxD,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChD,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;oBAC9C,QAAQ,CAAC,WAAW,CAClB,IAAI,EACJ,UAAU,CAAC,kBAAkB,EAC7B,IAAI,CAAC,QAAQ,CACd,CAAC;gBACJ,CAAC;qBAAM,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACrD,QAAQ,CAAC,WAAW,CAClB,IAAI,EACJ,UAAU,CAAC,kBAAkB,EAC7B,IAAI,CAAC,QAAQ,CACd,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAaF,EAAE;QACF,oBAAoB;QACpB,EAAE;QAEF,6BAAwB,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W,GAAG,IAAI,CAAC;YACtD,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ColliderObject3D from "../three/ColliderObject3D";
|
|
2
|
+
import { PCollider as PColliderBase } from "@p100-web/core";
|
|
3
|
+
export default class PCollider extends PColliderBase {
|
|
4
|
+
protected _el: ColliderObject3D | null;
|
|
5
|
+
protected _unrender(): void;
|
|
6
|
+
dispose(): void;
|
|
7
|
+
render(): void;
|
|
8
|
+
unrender(): void;
|
|
9
|
+
protected computeBounds(): void;
|
|
10
|
+
show(): void;
|
|
11
|
+
hide(): void;
|
|
12
|
+
/**
|
|
13
|
+
* This is called by PNode->set_el
|
|
14
|
+
*/
|
|
15
|
+
addColliderObject(): void;
|
|
16
|
+
removeColliderObject(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=PCollider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PCollider.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PCollider.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,aAAa;IAClD,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAE9C,SAAS,CAAC,SAAS;IAUnB,OAAO,IAAI,IAAI;IAMf,MAAM;IAGN,QAAQ;IAIR,SAAS,CAAC,aAAa;IAIvB,IAAI,IAAI,IAAI;IAIZ,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAqBzB,oBAAoB,IAAI,IAAI;CAG7B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import ColliderObject3D from "../three/ColliderObject3D";
|
|
2
|
+
import { PCollider as PColliderBase } from "@p100-web/core";
|
|
3
|
+
export default class PCollider extends PColliderBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this._el = null;
|
|
7
|
+
}
|
|
8
|
+
_unrender() {
|
|
9
|
+
if (this._el !== null) {
|
|
10
|
+
// Add me to the raycaster
|
|
11
|
+
this.context.getPCanvas().removeCollider(this._el);
|
|
12
|
+
this._el.dispose();
|
|
13
|
+
this._el.removeFromParent();
|
|
14
|
+
this._el = null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
dispose() {
|
|
18
|
+
if (this.node.collider === this) {
|
|
19
|
+
this.node.collider = null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
}
|
|
24
|
+
unrender() {
|
|
25
|
+
this._unrender();
|
|
26
|
+
}
|
|
27
|
+
computeBounds() {
|
|
28
|
+
this._el?.computeBounds(this);
|
|
29
|
+
}
|
|
30
|
+
show() {
|
|
31
|
+
this._el?.show(this);
|
|
32
|
+
}
|
|
33
|
+
hide() {
|
|
34
|
+
this._el?.hide();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* This is called by PNode->set_el
|
|
38
|
+
*/
|
|
39
|
+
addColliderObject() {
|
|
40
|
+
if (!this.node.hasEl()) {
|
|
41
|
+
this.context.error("PCollider had no el");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this._el) {
|
|
45
|
+
this.context.error("PCollider already had ColliderObject3D");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this._el = new ColliderObject3D(this);
|
|
49
|
+
const nodeEl = this.node.getEl();
|
|
50
|
+
nodeEl.add(this._el);
|
|
51
|
+
this.computeBounds();
|
|
52
|
+
// Add me to the raycaster
|
|
53
|
+
this.context.getPCanvas().addCollider(this._el);
|
|
54
|
+
}
|
|
55
|
+
removeColliderObject() {
|
|
56
|
+
this._unrender();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=PCollider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PCollider.js","sourceRoot":"","sources":["../../src/pcomponents/PCollider.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,aAAa;IAApD;;QACY,QAAG,GAA4B,IAAI,CAAC;IAgEhD,CAAC;IA9DW,SAAS;QACjB,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YACtB,0BAA0B;YAC1B,IAAI,CAAC,OAAO,CAAC,UAAU,EAAe,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAChE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,MAAM;IACN,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,IAAI;QACF,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,IAAI;QACF,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC7D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAY,CAAC;QAE3C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,0BAA0B;QAC1B,IAAI,CAAC,OAAO,CAAC,UAAU,EAAe,CAAC,WAAW,CAAC,IAAI,CAAC,GAAI,CAAC,CAAC;IAChE,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Mesh } from "three";
|
|
2
|
+
import { PCubeGeometry as PCubeGeometryBase } from "@p100-web/core";
|
|
3
|
+
export default class PCubeGeometry extends PCubeGeometryBase {
|
|
4
|
+
protected _mesh: Mesh | null;
|
|
5
|
+
unrender(): void;
|
|
6
|
+
render(): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=PCubeGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PCubeGeometry.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PCubeGeometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,iBAAiB;IAC1D,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEpC,QAAQ;IAOR,MAAM;CAQP"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Mesh, BoxGeometry } from "three";
|
|
2
|
+
import { PCubeGeometry as PCubeGeometryBase } from "@p100-web/core";
|
|
3
|
+
export default class PCubeGeometry extends PCubeGeometryBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this._mesh = null;
|
|
7
|
+
}
|
|
8
|
+
unrender() {
|
|
9
|
+
if (this._mesh) {
|
|
10
|
+
this._mesh.geometry.dispose();
|
|
11
|
+
this._mesh = null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
const geometry = new BoxGeometry(this.size.x, this.size.y, this.size.z);
|
|
16
|
+
const mesh = new Mesh(geometry);
|
|
17
|
+
mesh.castShadow = this.castShadow;
|
|
18
|
+
mesh.receiveShadow = this.receiveShadow;
|
|
19
|
+
this.node.set_el(mesh);
|
|
20
|
+
this._mesh = mesh;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=PCubeGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PCubeGeometry.js","sourceRoot":"","sources":["../../src/pcomponents/PCubeGeometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,iBAAiB;IAA5D;;QACY,UAAK,GAAgB,IAAI,CAAC;IAiBtC,CAAC;IAfC,QAAQ;QACN,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Texture } from "three";
|
|
2
|
+
import { PEnvironment as PEnvironmentBase } from "@p100-web/core";
|
|
3
|
+
import { HDRTextureTask, type IHDRTextureTaskLoader } from "../assets/ThreeAssetLoader";
|
|
4
|
+
export default class PEnvironment extends PEnvironmentBase implements IHDRTextureTaskLoader {
|
|
5
|
+
_texture: Texture | null;
|
|
6
|
+
getTexture<T>(): T | null;
|
|
7
|
+
_dispose(): void;
|
|
8
|
+
unrender(): void;
|
|
9
|
+
render(): void;
|
|
10
|
+
onHDRTextureTaskLoaded: (task: HDRTextureTask) => void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=PEnvironment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PEnvironment.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PEnvironment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,OAAyB,EACvB,cAAc,EACd,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,YACnB,SAAQ,gBACR,YAAW,qBAAqB;IAEhC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAQ;IAEhC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI;IAQzB,QAAQ;IASR,QAAQ;IAIR,MAAM;IAWN,sBAAsB,GAAI,MAAM,cAAc,KAAG,IAAI,CAInD;CACH"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PEnvironment as PEnvironmentBase } from "@p100-web/core";
|
|
2
|
+
export default class PEnvironment extends PEnvironmentBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this._texture = null;
|
|
6
|
+
//
|
|
7
|
+
// HDRTextureTask
|
|
8
|
+
//
|
|
9
|
+
this.onHDRTextureTaskLoaded = (task) => {
|
|
10
|
+
this._texture = task.texture;
|
|
11
|
+
const pcanvas = this.context.getPCanvas();
|
|
12
|
+
pcanvas.setEnvironment(this);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getTexture() {
|
|
16
|
+
return this._texture;
|
|
17
|
+
}
|
|
18
|
+
//
|
|
19
|
+
// PComponent
|
|
20
|
+
//
|
|
21
|
+
_dispose() {
|
|
22
|
+
const pcanvas = this.context.getPCanvas();
|
|
23
|
+
if (this._texture) {
|
|
24
|
+
pcanvas.clearEnvironment(this);
|
|
25
|
+
}
|
|
26
|
+
this._texture?.dispose();
|
|
27
|
+
this._texture = null;
|
|
28
|
+
}
|
|
29
|
+
unrender() {
|
|
30
|
+
this._dispose();
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
const engine = this.context.getIEngine().getEngineType();
|
|
34
|
+
this.context
|
|
35
|
+
.assetLoader()
|
|
36
|
+
.addHDRTextureTask(this, this._urls[engine][this.value]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=PEnvironment.js.map
|