lythreeframe 1.0.5 → 1.0.6
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/bundle.cjs.js +2646 -0
- package/dist/bundle.esm.js +2612 -0
- package/{src/index.ts → dist/index.d.ts} +40 -44
- package/dist/lythreeframe/AssetManagement/AssetDefines.d.ts +6 -0
- package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +23 -0
- package/dist/lythreeframe/AssetManagement/AssetPointer/AssetPointer.d.ts +9 -0
- package/dist/lythreeframe/AssetManagement/Task/Task.d.ts +7 -0
- package/dist/lythreeframe/Container/SmartPointer.d.ts +10 -0
- package/dist/lythreeframe/Defines.d.ts +4 -0
- package/dist/lythreeframe/Delegate.d.ts +8 -0
- package/dist/lythreeframe/Factory/CameraFactory.d.ts +20 -0
- package/dist/lythreeframe/Factory/RendererFactory.d.ts +2 -0
- package/dist/lythreeframe/Frame/Controller.d.ts +40 -0
- package/dist/lythreeframe/Frame/Viewport.d.ts +50 -0
- package/dist/lythreeframe/Frame/World.d.ts +18 -0
- package/dist/lythreeframe/Geometry/PlaneGeometry.d.ts +3 -0
- package/dist/lythreeframe/Geometry/TriangleGeometry.d.ts +3 -0
- package/dist/lythreeframe/Library/ContainerLibrary.d.ts +3 -0
- package/dist/lythreeframe/Library/Math.d.ts +27 -0
- package/dist/lythreeframe/Library/ResourceLibrary.d.ts +6 -0
- package/dist/lythreeframe/Object/Actor.d.ts +86 -0
- package/dist/lythreeframe/Object/Actors/Camera/CameraActor.d.ts +4 -0
- package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +7 -0
- package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +5 -0
- package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +9 -0
- package/dist/lythreeframe/Object/BaseObject.d.ts +10 -0
- package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +13 -0
- package/dist/lythreeframe/Object/Components/Camera/CameraComponent.d.ts +26 -0
- package/dist/lythreeframe/Object/Components/Component.d.ts +17 -0
- package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +15 -0
- package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +12 -0
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.d.ts +7 -0
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.d.ts +13 -0
- package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +22 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +8 -0
- package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +66 -0
- package/dist/lythreeframe/Object/PawnV2/FirstPerson.d.ts +5 -0
- package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +12 -0
- package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +14 -0
- package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +46 -0
- package/dist/lythreeframe/PostProcess/Param/Bloom.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/DOF.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/Denoise.d.ts +7 -0
- package/dist/lythreeframe/PostProcess/Param/GTAO.d.ts +11 -0
- package/dist/lythreeframe/PostProcess/Param/LensFlare.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/MotionBlur.d.ts +4 -0
- package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +17 -0
- package/dist/lythreeframe/PostProcess/Param/SSR.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +9 -0
- package/dist/lythreeframe/PostProcess/PostProcessParam.d.ts +16 -0
- package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +43 -0
- package/dist/lythreeframe/Shader/Postprocess/ColorShader.d.ts +29 -0
- package/dist/lythreeframe/ThreeJsApp.d.ts +35 -0
- package/package.json +26 -14
- package/dist/index.ts +0 -80
- package/rollup.config.js +0 -31
- package/src/draco/README.md +0 -32
- package/src/draco/draco_decoder.js +0 -34
- package/src/draco/draco_decoder.wasm +0 -0
- package/src/draco/draco_encoder.js +0 -33
- package/src/draco/draco_wasm_wrapper.js +0 -117
- package/src/draco/gltf/draco_decoder.js +0 -33
- package/src/draco/gltf/draco_decoder.wasm +0 -0
- package/src/draco/gltf/draco_encoder.js +0 -33
- package/src/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/src/lythreeframe/AssetManagement/AssetDefines.ts +0 -8
- package/src/lythreeframe/AssetManagement/AssetManager.ts +0 -288
- package/src/lythreeframe/AssetManagement/AssetPointer/AssetPointer.ts +0 -41
- package/src/lythreeframe/AssetManagement/Task/Task.ts +0 -24
- package/src/lythreeframe/Container/SmartPointer.ts +0 -54
- package/src/lythreeframe/Defines.ts +0 -11
- package/src/lythreeframe/Delegate.ts +0 -37
- package/src/lythreeframe/Factory/CameraFactory.ts +0 -81
- package/src/lythreeframe/Factory/RendererFactory.ts +0 -7
- package/src/lythreeframe/Frame/Controller.ts +0 -261
- package/src/lythreeframe/Frame/Viewport.ts +0 -516
- package/src/lythreeframe/Frame/World.ts +0 -59
- package/src/lythreeframe/Frame.ts +0 -511
- package/src/lythreeframe/Geometry/PlaneGeometry.ts +0 -53
- package/src/lythreeframe/Geometry/TriangleGeometry.ts +0 -50
- package/src/lythreeframe/Library/ContainerLibrary.ts +0 -21
- package/src/lythreeframe/Library/MaterialLibrary.ts +0 -292
- package/src/lythreeframe/Library/Math.ts +0 -154
- package/src/lythreeframe/Library/ResourceLibrary.ts +0 -21
- package/src/lythreeframe/Object/Actor.ts +0 -571
- package/src/lythreeframe/Object/Actors/Camera/CameraActor.ts +0 -11
- package/src/lythreeframe/Object/Actors/Light/DirectionalLightActor.ts +0 -18
- package/src/lythreeframe/Object/Actors/Shape/BoxActor.ts +0 -20
- package/src/lythreeframe/Object/Actors/Shape/CurveActor.ts +0 -11
- package/src/lythreeframe/Object/Actors/Shape/PlaneActor.ts +0 -27
- package/src/lythreeframe/Object/Actors/Shape/TubeActor.ts +0 -37
- package/src/lythreeframe/Object/BaseObject.ts +0 -45
- package/src/lythreeframe/Object/Components/2D/2DComponent.ts +0 -64
- package/src/lythreeframe/Object/Components/Camera/CameraComponent.ts +0 -113
- package/src/lythreeframe/Object/Components/Component.ts +0 -67
- package/src/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts +0 -78
- package/src/lythreeframe/Object/Components/Light/LightComponent.ts +0 -54
- package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.ts +0 -39
- package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.ts +0 -115
- package/src/lythreeframe/Object/Components/Mesh/Line/CurveComponent.ts +0 -221
- package/src/lythreeframe/Object/Components/Mesh/MeshComponent.ts +0 -162
- package/src/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.ts +0 -17
- package/src/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.ts +0 -10
- package/src/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.ts +0 -10
- package/src/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.ts +0 -32
- package/src/lythreeframe/Object/Components/SceneComponent.ts +0 -811
- package/src/lythreeframe/Object/Controller/Controller.ts +0 -764
- package/src/lythreeframe/Object/Pawn/CameraStatus.ts +0 -262
- package/src/lythreeframe/Object/Pawn/FirstPerson.ts +0 -230
- package/src/lythreeframe/Object/Pawn/Oribital.ts +0 -276
- package/src/lythreeframe/Object/Pawn/PawnBase.ts +0 -189
- package/src/lythreeframe/Object/Pawn/TopView.ts +0 -205
- package/src/lythreeframe/Object/Pawn/TransformControl.ts +0 -215
- package/src/lythreeframe/Object/Pawn/staticCamera.ts +0 -80
- package/src/lythreeframe/Object/PawnV2/FirstPerson.ts +0 -12
- package/src/lythreeframe/Object/PawnV2/Oribital.ts +0 -45
- package/src/lythreeframe/Object/PawnV2/Pawn.ts +0 -50
- package/src/lythreeframe/Object/PawnV2/TransformControl.ts +0 -202
- package/src/lythreeframe/PostProcess/Param/Bloom.ts +0 -12
- package/src/lythreeframe/PostProcess/Param/DOF.ts +0 -13
- package/src/lythreeframe/PostProcess/Param/Denoise.ts +0 -14
- package/src/lythreeframe/PostProcess/Param/GTAO.ts +0 -21
- package/src/lythreeframe/PostProcess/Param/LensFlare.ts +0 -11
- package/src/lythreeframe/PostProcess/Param/MotionBlur.ts +0 -8
- package/src/lythreeframe/PostProcess/Param/Outline.ts +0 -20
- package/src/lythreeframe/PostProcess/Param/SSR.ts +0 -11
- package/src/lythreeframe/PostProcess/Param/ToneMapping.ts +0 -31
- package/src/lythreeframe/PostProcess/PostProcessParam.ts +0 -26
- package/src/lythreeframe/PostProcess/WebGPUPostProcessFactory.ts +0 -217
- package/src/lythreeframe/Shader/Postprocess/ColorShader.ts +0 -49
- package/src/lythreeframe/ThreeJsApp.ts +0 -124
- package/tsconfig.json +0 -105
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* virtual class of 3D Object, should not be use directly.
|
|
4
|
-
*/
|
|
5
|
-
import {MathUtils} from "three";
|
|
6
|
-
|
|
7
|
-
export abstract class BaseObject
|
|
8
|
-
{
|
|
9
|
-
get IsTickable(): boolean
|
|
10
|
-
{
|
|
11
|
-
return this.bCanTick;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
set IsTickable(bCanTick)
|
|
15
|
-
{
|
|
16
|
-
this.bCanTick = bCanTick ;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get uuid(): string
|
|
20
|
-
{
|
|
21
|
-
return this._uuid;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
protected bCanTick: boolean = false;
|
|
25
|
-
protected _uuid : string;
|
|
26
|
-
protected constructor(uuid:string = MathUtils.generateUUID())
|
|
27
|
-
{
|
|
28
|
-
this.bCanTick = false;
|
|
29
|
-
this._uuid = uuid
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
tick(deltaTime:number) : void
|
|
33
|
-
{
|
|
34
|
-
if(!this.bCanTick)
|
|
35
|
-
{
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
destroy() : void
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { CSS2DObject } from "three/examples/jsm/renderers/CSS2DRenderer.js";
|
|
4
|
-
import { Vector2} from "three";
|
|
5
|
-
import {SceneComponent} from "../SceneComponent";
|
|
6
|
-
|
|
7
|
-
export class LabelComponent extends SceneComponent
|
|
8
|
-
{
|
|
9
|
-
get threeObject():CSS2DObject
|
|
10
|
-
{
|
|
11
|
-
return this.obj;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
set threeObject(newThreeObject:CSS2DObject)
|
|
15
|
-
{
|
|
16
|
-
this.obj = newThreeObject;
|
|
17
|
-
if (this.obj)
|
|
18
|
-
{
|
|
19
|
-
this.obj.userData["LYObject"] = this;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
protected obj:CSS2DObject
|
|
23
|
-
|
|
24
|
-
constructor(domElement:HTMLElement, center = new Vector2(0.5, 1))
|
|
25
|
-
{
|
|
26
|
-
let obj = new CSS2DObject( domElement )
|
|
27
|
-
super(obj)
|
|
28
|
-
this.obj = obj;
|
|
29
|
-
obj.center = center;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override set isHoverEnabled(bCanHorver: boolean)
|
|
33
|
-
{
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
override set isClickEnabled(bCanClick: boolean)
|
|
38
|
-
{
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setVisible(bVisible:boolean)
|
|
43
|
-
{
|
|
44
|
-
super.setVisible(bVisible)
|
|
45
|
-
}
|
|
46
|
-
destroy()
|
|
47
|
-
{
|
|
48
|
-
if (this.threeObject.element && this.threeObject.element.parentNode) {
|
|
49
|
-
this.threeObject.element.innerHTML = '';
|
|
50
|
-
this.threeObject.element.remove();
|
|
51
|
-
}
|
|
52
|
-
super.destroy();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// example
|
|
57
|
-
// const labelStyle = document.createElement( 'div' );
|
|
58
|
-
//
|
|
59
|
-
// labelStyle.textContent = "this.POIData.name";
|
|
60
|
-
// labelStyle.className = 'label';
|
|
61
|
-
// labelStyle.style.color = 'white'
|
|
62
|
-
// labelStyle.style.backgroundColor = 'transparent';
|
|
63
|
-
// labelStyle.style.fontSize = "10px";
|
|
64
|
-
// labelStyle.style.pointerEvents = 'auto';
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {SceneComponent} from "../SceneComponent";
|
|
2
|
-
import {OrthographicCamera, PerspectiveCamera} from "three";
|
|
3
|
-
|
|
4
|
-
interface CameraParam
|
|
5
|
-
{
|
|
6
|
-
near:number,
|
|
7
|
-
far:number,
|
|
8
|
-
param:PerspectiveCameraParam | OrthographicCameraParam
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface PerspectiveCameraParam
|
|
12
|
-
{
|
|
13
|
-
fov:number,
|
|
14
|
-
aspect:number,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface OrthographicCameraParam
|
|
18
|
-
{
|
|
19
|
-
left:number,
|
|
20
|
-
right:number,
|
|
21
|
-
top:number,
|
|
22
|
-
bottom:number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class CameraComponent extends SceneComponent
|
|
26
|
-
{
|
|
27
|
-
get threeObject():PerspectiveCamera | OrthographicCamera
|
|
28
|
-
{
|
|
29
|
-
return this.obj;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get camera():PerspectiveCamera | OrthographicCamera
|
|
33
|
-
{
|
|
34
|
-
return this.obj;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private set threeObject(newThreeObject:PerspectiveCamera | OrthographicCamera)
|
|
38
|
-
{
|
|
39
|
-
this.obj = newThreeObject;
|
|
40
|
-
if (this.obj)
|
|
41
|
-
{
|
|
42
|
-
this.obj.userData["LYObject"] = this;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
protected obj:PerspectiveCamera | OrthographicCamera;
|
|
47
|
-
|
|
48
|
-
constructor(param?:CameraParam)
|
|
49
|
-
{
|
|
50
|
-
if (!param)
|
|
51
|
-
{
|
|
52
|
-
param = {
|
|
53
|
-
near :0.1,
|
|
54
|
-
far :1000,
|
|
55
|
-
param:{
|
|
56
|
-
fov :50,
|
|
57
|
-
aspect:1
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
let cam:PerspectiveCamera | OrthographicCamera | null = null;
|
|
62
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
63
|
-
{
|
|
64
|
-
cam = new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
65
|
-
}
|
|
66
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
67
|
-
{
|
|
68
|
-
cam = new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
69
|
-
}
|
|
70
|
-
if (!cam)
|
|
71
|
-
{
|
|
72
|
-
console.error("create camera failed");
|
|
73
|
-
debugger
|
|
74
|
-
throw Error("create camera failed");
|
|
75
|
-
}
|
|
76
|
-
super(cam);
|
|
77
|
-
this.obj = cam;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
updateCamera(param:CameraParam)
|
|
81
|
-
{
|
|
82
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
83
|
-
{
|
|
84
|
-
if (this.obj instanceof PerspectiveCamera)
|
|
85
|
-
{
|
|
86
|
-
this.obj.near = param.near;
|
|
87
|
-
this.obj.far = param.far;
|
|
88
|
-
this.obj.fov = param.param.fov;
|
|
89
|
-
this.obj.aspect = param.param.aspect;
|
|
90
|
-
}
|
|
91
|
-
else
|
|
92
|
-
{
|
|
93
|
-
this.obj = new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
97
|
-
{
|
|
98
|
-
if (this.obj instanceof OrthographicCamera)
|
|
99
|
-
{
|
|
100
|
-
this.obj.near = param.near;
|
|
101
|
-
this.obj.far = param.far;
|
|
102
|
-
this.obj.left = param.param.left;
|
|
103
|
-
this.obj.right = param.param.right;
|
|
104
|
-
this.obj.top = param.param.top;
|
|
105
|
-
this.obj.bottom = param.param.bottom;
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
{
|
|
109
|
-
this.obj = new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Object3D} from "three";
|
|
2
|
-
import {BaseObject} from "../BaseObject";
|
|
3
|
-
import {Actor} from "../Actor";
|
|
4
|
-
|
|
5
|
-
export abstract class Component extends BaseObject
|
|
6
|
-
{
|
|
7
|
-
set parentActor(value:Actor|null)
|
|
8
|
-
{
|
|
9
|
-
this._parentActor = value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get parentActor():Actor | null
|
|
13
|
-
{
|
|
14
|
-
return this._parentActor;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get threeObject():Object3D|null
|
|
18
|
-
{
|
|
19
|
-
return this.obj;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
set threeObject(newThreeObject:Object3D)
|
|
23
|
-
{
|
|
24
|
-
this.obj = newThreeObject;
|
|
25
|
-
if (this.obj)
|
|
26
|
-
{
|
|
27
|
-
this.obj.userData["LYObject"] = this;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
get name():string
|
|
31
|
-
{
|
|
32
|
-
return this._name
|
|
33
|
-
}
|
|
34
|
-
set name(name:string)
|
|
35
|
-
{
|
|
36
|
-
this._name = name;
|
|
37
|
-
}
|
|
38
|
-
protected obj:Object3D|null = null;
|
|
39
|
-
protected _parentActor:Actor | null = null;
|
|
40
|
-
protected _name = "Component";
|
|
41
|
-
protected constructor(newThreeObject:Object3D)
|
|
42
|
-
{
|
|
43
|
-
super(newThreeObject.uuid);
|
|
44
|
-
this._parentActor = null;
|
|
45
|
-
this.threeObject = newThreeObject;
|
|
46
|
-
this._name = `${newThreeObject.type}Component`;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
destroyObject():void
|
|
53
|
-
{
|
|
54
|
-
if (!this.obj)
|
|
55
|
-
{
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
destroy():void
|
|
61
|
-
{
|
|
62
|
-
this.destroyObject();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
package/src/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {LightComponent} from "../LightComponent";
|
|
2
|
-
import {ColorRepresentation, DirectionalLight, Vector3} from "three";
|
|
3
|
-
import { World } from "../../../../Frame/World";
|
|
4
|
-
|
|
5
|
-
export class DirectionalLightComponent extends LightComponent
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
get threeObject():DirectionalLight
|
|
9
|
-
{
|
|
10
|
-
if(!this.obj)
|
|
11
|
-
{
|
|
12
|
-
throw Error("three object is invalid")
|
|
13
|
-
}
|
|
14
|
-
return this.obj;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
set threeObject(newThreeObject:DirectionalLight)
|
|
18
|
-
{
|
|
19
|
-
this.obj = newThreeObject;
|
|
20
|
-
if (this.obj)
|
|
21
|
-
{
|
|
22
|
-
this.obj.userData["LYObject"] = this;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get castShadow(): boolean
|
|
28
|
-
{
|
|
29
|
-
return this.threeObject.castShadow;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
set castShadow(value: boolean)
|
|
33
|
-
{
|
|
34
|
-
this.threeObject.castShadow = value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected obj:DirectionalLight|null;
|
|
38
|
-
|
|
39
|
-
constructor(color:ColorRepresentation = 0xffffff, intensity = 10)
|
|
40
|
-
{
|
|
41
|
-
let obj = new DirectionalLight(color, intensity);
|
|
42
|
-
super(obj);
|
|
43
|
-
this.obj = obj;
|
|
44
|
-
obj.castShadow = true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setPosition(...args:[Vector3] | [number, number, number])
|
|
48
|
-
{
|
|
49
|
-
if(args.length === 1)
|
|
50
|
-
{
|
|
51
|
-
super.setPosition(args[0]);
|
|
52
|
-
}
|
|
53
|
-
else
|
|
54
|
-
{
|
|
55
|
-
super.setPosition(args[0],args[1],args[2]);
|
|
56
|
-
}
|
|
57
|
-
this.update();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
update()
|
|
61
|
-
{
|
|
62
|
-
if (this.world)
|
|
63
|
-
this.world.viewport.markRenderStateDirty();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
onAddedToWorld(world:World)
|
|
67
|
-
{
|
|
68
|
-
if(!this.threeObject)
|
|
69
|
-
{
|
|
70
|
-
throw Error("three object is invalid")
|
|
71
|
-
}
|
|
72
|
-
super.onAddedToWorld(world);
|
|
73
|
-
}
|
|
74
|
-
destroy()
|
|
75
|
-
{
|
|
76
|
-
super.destroy();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* virtual class of light, should not be use directly.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { ColorRepresentation, Light} from "three";
|
|
6
|
-
import {SceneComponent} from "../SceneComponent";
|
|
7
|
-
|
|
8
|
-
export abstract class LightComponent extends SceneComponent
|
|
9
|
-
{
|
|
10
|
-
get threeObject(): Light
|
|
11
|
-
{
|
|
12
|
-
if(!this.obj)
|
|
13
|
-
{
|
|
14
|
-
throw Error("three object is invalid")
|
|
15
|
-
}
|
|
16
|
-
return this.obj
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
set threeObject(newThreeObject: Light)
|
|
20
|
-
{
|
|
21
|
-
this.obj = newThreeObject;
|
|
22
|
-
if (this.obj)
|
|
23
|
-
{
|
|
24
|
-
this.obj.userData["LYObject"] = this;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get color(): number
|
|
29
|
-
{
|
|
30
|
-
return this.threeObject.color.getHex()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
set color(color: ColorRepresentation)
|
|
34
|
-
{
|
|
35
|
-
this.threeObject.color.set(color)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get intensity(): number
|
|
39
|
-
{
|
|
40
|
-
return this.threeObject.intensity
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set intensity(intensity: number)
|
|
44
|
-
{
|
|
45
|
-
this.threeObject.intensity = intensity
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected obj: Light|null
|
|
49
|
-
protected constructor(light:Light)
|
|
50
|
-
{
|
|
51
|
-
super(light);
|
|
52
|
-
this.obj = light
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {BufferGeometry, InstancedMesh, Material, Matrix4} from "three";
|
|
2
|
-
|
|
3
|
-
import { MeshComponent } from "../MeshComponent";
|
|
4
|
-
|
|
5
|
-
export class LYInstanceMeshComponent extends MeshComponent
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
constructor(geometry:BufferGeometry, material:Material|Material[], matrices:Matrix4[])
|
|
9
|
-
{
|
|
10
|
-
let newInstanceMesh = new InstancedMesh(geometry,material,matrices.length);
|
|
11
|
-
super(newInstanceMesh)
|
|
12
|
-
|
|
13
|
-
this.update(matrices)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
update(matrices:Matrix4[])
|
|
17
|
-
{
|
|
18
|
-
if(!(this.threeObject instanceof InstancedMesh))
|
|
19
|
-
{
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
this.threeObject.count = matrices.length
|
|
23
|
-
for(let i = 0; i < matrices.length; i++)
|
|
24
|
-
{
|
|
25
|
-
this.threeObject.setMatrixAt(i, matrices[i]);
|
|
26
|
-
}
|
|
27
|
-
this.threeObject.instanceMatrix.needsUpdate = true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
destroy()
|
|
31
|
-
{
|
|
32
|
-
if(this.threeObject instanceof InstancedMesh)
|
|
33
|
-
{
|
|
34
|
-
this.threeObject.dispose()
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
super.destroy();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {Group, Matrix4, Mesh, Object3D,} from "three";
|
|
2
|
-
import {SceneComponent} from "../../SceneComponent";
|
|
3
|
-
import {LYInstanceMeshComponent} from "./InstanceMeshComponent";
|
|
4
|
-
|
|
5
|
-
interface MeshData
|
|
6
|
-
{
|
|
7
|
-
matrix: Matrix4
|
|
8
|
-
component: LYInstanceMeshComponent
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class LYMultiInstanceMeshComponent extends SceneComponent
|
|
12
|
-
{
|
|
13
|
-
get matrices(): Matrix4[]
|
|
14
|
-
{
|
|
15
|
-
return this._matrices;
|
|
16
|
-
}
|
|
17
|
-
private ins: LYInstanceMeshComponent[] = []
|
|
18
|
-
private count: number = 0
|
|
19
|
-
private object: Object3D
|
|
20
|
-
private _matrices:Matrix4[] = []
|
|
21
|
-
constructor(object: Object3D, matrices: Matrix4[])
|
|
22
|
-
{
|
|
23
|
-
super(new Group())
|
|
24
|
-
this.object = object.clone(true)
|
|
25
|
-
this._matrices = matrices
|
|
26
|
-
this.collectMeshes(this.object, matrices)
|
|
27
|
-
this.update(matrices)
|
|
28
|
-
this.count = matrices.length
|
|
29
|
-
this.setMatrix(this.object.matrix)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private collectMeshes(object: Object3D, matrices: Matrix4[])
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
const objectInvertWorldMatrix = object.matrixWorld.clone().invert()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
object.traverse((elem) =>
|
|
39
|
-
{
|
|
40
|
-
if (elem instanceof Mesh)
|
|
41
|
-
{
|
|
42
|
-
// if (elem instanceof InstancedMesh)
|
|
43
|
-
// {
|
|
44
|
-
//
|
|
45
|
-
// const elemWorldMatrix = elem.matrixWorld.clone()
|
|
46
|
-
// const relativeMatrix = new Matrix4();
|
|
47
|
-
// relativeMatrix.multiplyMatrices(objectInvertWorldMatrix, elemWorldMatrix);
|
|
48
|
-
//
|
|
49
|
-
// let localMatrix: Matrix4[] = []
|
|
50
|
-
// for (let i = 0; i < elem.count; ++i)
|
|
51
|
-
// {
|
|
52
|
-
// for (let j = 0; j < matrices.length; ++j)
|
|
53
|
-
// {
|
|
54
|
-
// let mat = new Matrix4()
|
|
55
|
-
// elem.getMatrixAt(i, mat)
|
|
56
|
-
// localMatrix.push(new Matrix4().multiplyMatrices(mat, matrices[j]))
|
|
57
|
-
// }
|
|
58
|
-
// }
|
|
59
|
-
//
|
|
60
|
-
// let insMeshComp = new LYInstanceMeshComponent(elem.geometry, elem.material, localMatrix)
|
|
61
|
-
// insMeshComp.setMatrix(relativeMatrix)
|
|
62
|
-
// this.addChildComponent(insMeshComp)
|
|
63
|
-
// this.ins.push(insMeshComp)
|
|
64
|
-
// }
|
|
65
|
-
// else
|
|
66
|
-
{
|
|
67
|
-
elem.updateMatrixWorld(true);
|
|
68
|
-
const elemWorldMatrix = elem.matrixWorld.clone()
|
|
69
|
-
const relativeMatrix = new Matrix4();
|
|
70
|
-
relativeMatrix.multiplyMatrices(objectInvertWorldMatrix, elemWorldMatrix);
|
|
71
|
-
|
|
72
|
-
let insMeshComp = new LYInstanceMeshComponent(elem.geometry, elem.material, matrices)
|
|
73
|
-
insMeshComp.setMatrix(relativeMatrix)
|
|
74
|
-
this.addChildComponent(insMeshComp)
|
|
75
|
-
this.ins.push(insMeshComp)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
update(matrices: Matrix4[])
|
|
83
|
-
{
|
|
84
|
-
this._matrices = matrices
|
|
85
|
-
|
|
86
|
-
if (matrices.length !== this.count)
|
|
87
|
-
{
|
|
88
|
-
this.ins.forEach((elem) =>
|
|
89
|
-
{
|
|
90
|
-
elem.destroy()
|
|
91
|
-
})
|
|
92
|
-
this.ins = []
|
|
93
|
-
this.collectMeshes(this.object, matrices)
|
|
94
|
-
this.count = matrices.length
|
|
95
|
-
}
|
|
96
|
-
else
|
|
97
|
-
{
|
|
98
|
-
this.ins.forEach((elem) =>
|
|
99
|
-
{
|
|
100
|
-
elem.update(matrices)
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
destroy()
|
|
107
|
-
{
|
|
108
|
-
this.ins.forEach((elem) =>
|
|
109
|
-
{
|
|
110
|
-
elem.destroy()
|
|
111
|
-
})
|
|
112
|
-
this.ins = []
|
|
113
|
-
super.destroy();
|
|
114
|
-
}
|
|
115
|
-
}
|