lythreeframe 1.0.0
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/lythreeFrame/exporter.ts +36 -0
- package/lythreeFrame/src/AssetManagement/AssetDefines.ts +8 -0
- package/lythreeFrame/src/AssetManagement/AssetManager.ts +286 -0
- package/lythreeFrame/src/AssetManagement/AssetPointer/AssetPointer.ts +41 -0
- package/lythreeFrame/src/AssetManagement/Task/Task.ts +24 -0
- package/lythreeFrame/src/Container/SmartPointer.ts +54 -0
- package/lythreeFrame/src/Defines.ts +11 -0
- package/lythreeFrame/src/Delegate.ts +37 -0
- package/lythreeFrame/src/Factory/CameraFactory.ts +81 -0
- package/lythreeFrame/src/Factory/RendererFactory.ts +7 -0
- package/lythreeFrame/src/Frame/Controller.ts +261 -0
- package/lythreeFrame/src/Frame/Viewport.ts +516 -0
- package/lythreeFrame/src/Frame/World.ts +59 -0
- package/lythreeFrame/src/Frame.ts +511 -0
- package/lythreeFrame/src/Geometry/PlaneGeometry.ts +53 -0
- package/lythreeFrame/src/Geometry/TriangleGeometry.ts +50 -0
- package/lythreeFrame/src/Library/ContainerLibrary.ts +21 -0
- package/lythreeFrame/src/Library/MaterialLibrary.ts +288 -0
- package/lythreeFrame/src/Library/Math.ts +154 -0
- package/lythreeFrame/src/Library/ResourceLibrary.ts +21 -0
- package/lythreeFrame/src/Object/Actor.ts +571 -0
- package/lythreeFrame/src/Object/Actors/Camera/CameraActor.ts +11 -0
- package/lythreeFrame/src/Object/Actors/Light/DirectionalLightActor.ts +18 -0
- package/lythreeFrame/src/Object/Actors/Shape/BoxActor.ts +20 -0
- package/lythreeFrame/src/Object/Actors/Shape/CurveActor.ts +11 -0
- package/lythreeFrame/src/Object/Actors/Shape/PlaneActor.ts +27 -0
- package/lythreeFrame/src/Object/Actors/Shape/TubeActor.ts +37 -0
- package/lythreeFrame/src/Object/BaseObject.ts +45 -0
- package/lythreeFrame/src/Object/Components/2D/2DComponent.ts +64 -0
- package/lythreeFrame/src/Object/Components/Camera/CameraComponent.ts +113 -0
- package/lythreeFrame/src/Object/Components/Component.ts +67 -0
- package/lythreeFrame/src/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts +78 -0
- package/lythreeFrame/src/Object/Components/Light/LightComponent.ts +54 -0
- package/lythreeFrame/src/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.ts +39 -0
- package/lythreeFrame/src/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.ts +115 -0
- package/lythreeFrame/src/Object/Components/Mesh/Line/CurveComponent.ts +221 -0
- package/lythreeFrame/src/Object/Components/Mesh/MeshComponent.ts +162 -0
- package/lythreeFrame/src/Object/Components/Mesh/Shape/BoxComponent.ts +17 -0
- package/lythreeFrame/src/Object/Components/Mesh/Shape/PlaneComponent.ts +10 -0
- package/lythreeFrame/src/Object/Components/Mesh/Shape/SphereComponent.ts +10 -0
- package/lythreeFrame/src/Object/Components/Mesh/Sprite/SpriteComponent.ts +32 -0
- package/lythreeFrame/src/Object/Components/SceneComponent.ts +809 -0
- package/lythreeFrame/src/Object/Controller/Controller.ts +764 -0
- package/lythreeFrame/src/Object/Pawn/CameraStatus.ts +262 -0
- package/lythreeFrame/src/Object/Pawn/FirstPerson.ts +230 -0
- package/lythreeFrame/src/Object/Pawn/Oribital.ts +276 -0
- package/lythreeFrame/src/Object/Pawn/PawnBase.ts +189 -0
- package/lythreeFrame/src/Object/Pawn/TopView.ts +205 -0
- package/lythreeFrame/src/Object/Pawn/TransformControl.ts +215 -0
- package/lythreeFrame/src/Object/Pawn/staticCamera.ts +80 -0
- package/lythreeFrame/src/Object/PawnV2/FirstPerson.ts +12 -0
- package/lythreeFrame/src/Object/PawnV2/Oribital.ts +45 -0
- package/lythreeFrame/src/Object/PawnV2/Pawn.ts +50 -0
- package/lythreeFrame/src/Object/PawnV2/TransformControl.ts +201 -0
- package/lythreeFrame/src/PostProcess/Param/Bloom.ts +12 -0
- package/lythreeFrame/src/PostProcess/Param/DOF.ts +14 -0
- package/lythreeFrame/src/PostProcess/Param/Denoise.ts +14 -0
- package/lythreeFrame/src/PostProcess/Param/GTAO.ts +21 -0
- package/lythreeFrame/src/PostProcess/Param/LensFlare.ts +11 -0
- package/lythreeFrame/src/PostProcess/Param/MotionBlur.ts +8 -0
- package/lythreeFrame/src/PostProcess/Param/Outline.ts +20 -0
- package/lythreeFrame/src/PostProcess/Param/SSR.ts +11 -0
- package/lythreeFrame/src/PostProcess/Param/ToneMapping.ts +31 -0
- package/lythreeFrame/src/PostProcess/PostProcessParam.ts +26 -0
- package/lythreeFrame/src/PostProcess/WebGPUPostProcessFactory.ts +217 -0
- package/lythreeFrame/src/Shader/Postprocess/ColorShader.ts +49 -0
- package/lythreeFrame/src/ThreeJsApp.ts +124 -0
- package/package.json +21 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import {Mesh, Vector3, Quaternion, Euler, Matrix4, Object3D, Group} from "three";
|
|
2
|
+
import {BaseObject} from "./BaseObject";
|
|
3
|
+
import {MeshComponent} from "./Components/Mesh/MeshComponent";
|
|
4
|
+
import {AttachmentRules} from "../Defines";
|
|
5
|
+
|
|
6
|
+
import {SceneComponent} from "./Components/SceneComponent.ts";
|
|
7
|
+
import { World } from "../Frame/World.ts";
|
|
8
|
+
|
|
9
|
+
export class Actor extends BaseObject
|
|
10
|
+
{
|
|
11
|
+
get world()
|
|
12
|
+
{
|
|
13
|
+
return this._world;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get name():string
|
|
17
|
+
{
|
|
18
|
+
console.log("getname", this._name)
|
|
19
|
+
return this._name;
|
|
20
|
+
}
|
|
21
|
+
set name(name:string)
|
|
22
|
+
{
|
|
23
|
+
this._name = name;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get rootComponent():SceneComponent
|
|
27
|
+
{
|
|
28
|
+
if(!this._rootComponent)
|
|
29
|
+
{
|
|
30
|
+
throw Error("rootComponent is invalid")
|
|
31
|
+
}
|
|
32
|
+
return this._rootComponent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
set rootComponent(newRoot:SceneComponent)
|
|
36
|
+
{
|
|
37
|
+
newRoot.detachFromParentComponent();
|
|
38
|
+
newRoot.parentActor = this;
|
|
39
|
+
if (this._rootComponent)
|
|
40
|
+
{
|
|
41
|
+
let child = this.rootComponent.childrenComponents;
|
|
42
|
+
for (let i = 0; i < child.length; ++i)
|
|
43
|
+
{
|
|
44
|
+
newRoot.addChildComponent(child[i]);
|
|
45
|
+
}
|
|
46
|
+
this.rootComponent.destroy();
|
|
47
|
+
}
|
|
48
|
+
this._rootComponent = newRoot;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get childrenComponents()
|
|
53
|
+
{
|
|
54
|
+
return this.rootComponent.childrenComponents;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get childActors():Actor[]
|
|
58
|
+
{
|
|
59
|
+
let ret:Actor[] = []
|
|
60
|
+
this.rootComponent.threeObject?.children.forEach((elem) =>{
|
|
61
|
+
let p = elem.userData["LYObject"]?.parentActor;
|
|
62
|
+
if(p !== this && p instanceof Actor)
|
|
63
|
+
{
|
|
64
|
+
ret.push(p);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
return ret;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get parentActor():Actor|null
|
|
71
|
+
{
|
|
72
|
+
let parent = this.rootComponent.threeObject?.parent?.userData["LYObject"].parentActor as Actor|null;
|
|
73
|
+
return parent === this ? null: parent;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get isVisible():boolean
|
|
77
|
+
{
|
|
78
|
+
return this.rootComponent ? this.rootComponent.isVisible : false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected _name:string = "Actor"
|
|
82
|
+
|
|
83
|
+
protected _rootComponent: SceneComponent|null = null;
|
|
84
|
+
protected _world : World | null = null;
|
|
85
|
+
|
|
86
|
+
protected onClickedEvent : ((component?:SceneComponent) => void)[] = [];
|
|
87
|
+
protected onDoubleClickedEvent : ((component?:SceneComponent) => void)[] = [];
|
|
88
|
+
protected onHoverBeginEvent: ((component?:SceneComponent) => void)[] = [];
|
|
89
|
+
protected onHoverEndEvent : ((component?:SceneComponent) => void)[] = [];
|
|
90
|
+
|
|
91
|
+
constructor(myThreeObject:Object3D|null = null)
|
|
92
|
+
{
|
|
93
|
+
super();
|
|
94
|
+
this.constructRootComponent(myThreeObject);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected constructRootComponent(myThreeObject:Object3D|null = null)
|
|
98
|
+
{
|
|
99
|
+
let tObject = myThreeObject ? myThreeObject : new Group()
|
|
100
|
+
if ((tObject as any).isMesh)
|
|
101
|
+
{
|
|
102
|
+
let mesh = tObject as Mesh
|
|
103
|
+
this._rootComponent = new MeshComponent(mesh);
|
|
104
|
+
this.rootComponent.parentActor = this;
|
|
105
|
+
}
|
|
106
|
+
else
|
|
107
|
+
{
|
|
108
|
+
this._rootComponent = new SceneComponent(tObject);
|
|
109
|
+
this.rootComponent.parentActor = this;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getBoundsCenterPosition(bInWorldSpace = true)
|
|
114
|
+
{
|
|
115
|
+
let ret = new Vector3();
|
|
116
|
+
this.getBounds().getCenter(ret);
|
|
117
|
+
if (!bInWorldSpace)
|
|
118
|
+
{
|
|
119
|
+
return ret.sub(this.getPosition());
|
|
120
|
+
}
|
|
121
|
+
else
|
|
122
|
+
{
|
|
123
|
+
return ret;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getBoundsTopCenterPosition(bInWorldSpace = true)
|
|
128
|
+
{
|
|
129
|
+
let ret = new Vector3();
|
|
130
|
+
let bounds = this.rootComponent.getBounds();
|
|
131
|
+
bounds.getCenter(ret);
|
|
132
|
+
ret.y = bounds.max.y;
|
|
133
|
+
if (!bInWorldSpace)
|
|
134
|
+
{
|
|
135
|
+
return ret.sub(this.getPosition());
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
{
|
|
139
|
+
return ret;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getBoundsBottomCenterPosition(bInWorldSpace = true)
|
|
144
|
+
{
|
|
145
|
+
let ret = new Vector3();
|
|
146
|
+
let bounds = this.getBounds();
|
|
147
|
+
bounds.getCenter(ret);
|
|
148
|
+
|
|
149
|
+
ret.y = bounds.min.y;
|
|
150
|
+
if (!bInWorldSpace)
|
|
151
|
+
{
|
|
152
|
+
return ret.sub(this.getPosition());
|
|
153
|
+
}
|
|
154
|
+
else
|
|
155
|
+
{
|
|
156
|
+
return ret;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getBounds()
|
|
161
|
+
{
|
|
162
|
+
return this.rootComponent.getBounds();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
destroy()
|
|
166
|
+
{
|
|
167
|
+
let childActors = this.childActors;
|
|
168
|
+
childActors.forEach((elem) =>
|
|
169
|
+
{
|
|
170
|
+
elem.destroy();
|
|
171
|
+
});
|
|
172
|
+
this.rootComponent.destroy();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setVisible(bVisible:boolean)
|
|
176
|
+
{
|
|
177
|
+
this.rootComponent.setVisible(bVisible);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setLayers(layer:number, bAffectChildActor = true)
|
|
181
|
+
{
|
|
182
|
+
this.rootComponent.setLayers(layer);
|
|
183
|
+
if (bAffectChildActor)
|
|
184
|
+
{
|
|
185
|
+
this.childActors.forEach((child) =>
|
|
186
|
+
{
|
|
187
|
+
child.setLayers(layer, bAffectChildActor);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
tick(deltaTime:number):void
|
|
194
|
+
{
|
|
195
|
+
super.tick(deltaTime);
|
|
196
|
+
this.rootComponent.tick(deltaTime);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Local Transforms
|
|
200
|
+
// // Position
|
|
201
|
+
getPosition():Vector3
|
|
202
|
+
{
|
|
203
|
+
return this.rootComponent.getPosition();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setPosition(position:Vector3):void;
|
|
207
|
+
setPosition(x:number, y:number, z:number):void;
|
|
208
|
+
setPosition(...args:[Vector3] | [number, number, number]):void
|
|
209
|
+
{
|
|
210
|
+
if(args.length === 1)
|
|
211
|
+
{
|
|
212
|
+
this.rootComponent.setPosition(args[0]);
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
{
|
|
216
|
+
this.rootComponent.setPosition(args[0],args[1],args[2]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// // Rotation (euler)
|
|
221
|
+
getRotation():Euler
|
|
222
|
+
{
|
|
223
|
+
return this.rootComponent.getRotation();
|
|
224
|
+
}
|
|
225
|
+
setRotation(rotation:Euler):void;
|
|
226
|
+
setRotation(x:number, y:number, z:number):void;
|
|
227
|
+
setRotation(...args:[Euler]|[x:number, y:number, z:number])
|
|
228
|
+
{
|
|
229
|
+
if(args.length === 1)
|
|
230
|
+
{
|
|
231
|
+
this.rootComponent.setRotation(args[0]);
|
|
232
|
+
}
|
|
233
|
+
else
|
|
234
|
+
{
|
|
235
|
+
this.rootComponent.setRotation(args[0],args[1],args[2]);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// // quat
|
|
240
|
+
getQuaternion():Quaternion
|
|
241
|
+
{
|
|
242
|
+
return this.rootComponent.getQuaternion();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
setQuaternion(quat:Quaternion):void;
|
|
246
|
+
setQuaternion(x:number, y:number, z:number, w:number):void;
|
|
247
|
+
setQuaternion(...args:[Quaternion]|[x:number, y:number, z:number, w:number])
|
|
248
|
+
{
|
|
249
|
+
if(args.length === 1)
|
|
250
|
+
{
|
|
251
|
+
this.rootComponent.setQuaternion(args[0]);
|
|
252
|
+
}
|
|
253
|
+
else
|
|
254
|
+
{
|
|
255
|
+
this.rootComponent.setQuaternion(args[0],args[1],args[2],args[3]);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// // Scale
|
|
260
|
+
getScale():Vector3
|
|
261
|
+
{
|
|
262
|
+
return this.rootComponent.getScale();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
setScale(position:Vector3):void;
|
|
266
|
+
setScale(x:number, y:number, z:number):void;
|
|
267
|
+
setScale(...args:[Vector3] | [number, number, number]):void
|
|
268
|
+
{
|
|
269
|
+
if(args.length === 1)
|
|
270
|
+
{
|
|
271
|
+
this.rootComponent.setScale(args[0]);
|
|
272
|
+
}
|
|
273
|
+
else
|
|
274
|
+
{
|
|
275
|
+
this.rootComponent.setScale(args[0],args[1],args[2]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// World Transform
|
|
279
|
+
// // Matrix
|
|
280
|
+
getWorldMatrix():Matrix4
|
|
281
|
+
{
|
|
282
|
+
return this.rootComponent.getWorldMatrix();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
setWorldMatrix(newMatrix:Matrix4):void
|
|
286
|
+
{
|
|
287
|
+
this.rootComponent.setWorldMatrix(newMatrix);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// // WorldPosition
|
|
291
|
+
getWorldPosition():Vector3
|
|
292
|
+
{
|
|
293
|
+
return this.rootComponent.getWorldPosition();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// setWorldPosition(param1, param2 = undefined, param3 = undefined)
|
|
297
|
+
// {
|
|
298
|
+
|
|
299
|
+
// }
|
|
300
|
+
// // rotation(euler)
|
|
301
|
+
getWorldRotation():Euler
|
|
302
|
+
{
|
|
303
|
+
return this.rootComponent.getWorldRotation();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// // rotation(quat)
|
|
307
|
+
getWorldQuaternion():Quaternion
|
|
308
|
+
{
|
|
309
|
+
return this.rootComponent.getWorldQuaternion();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// // Scale
|
|
313
|
+
getWorldScale():Vector3
|
|
314
|
+
{
|
|
315
|
+
return this.rootComponent.getWorldScale();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
getWorldForwardDirection():Vector3
|
|
319
|
+
{
|
|
320
|
+
return this.rootComponent.getWorldForwardDirection();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
getWorldUpDirection():Vector3
|
|
324
|
+
{
|
|
325
|
+
return this.rootComponent.getWorldUpDirection();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
getWorldRightDirection():Vector3
|
|
329
|
+
{
|
|
330
|
+
return this.rootComponent.getWorldRightDirection();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
addLocalOffset(axis:Vector3, value:number)
|
|
334
|
+
{
|
|
335
|
+
let pos = this.getPosition();
|
|
336
|
+
this.setPosition(pos.x + axis.x * value, pos.y + axis.y * value, pos.z + axis.z * value);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
worldToLocal(vec:Vector3):Vector3
|
|
340
|
+
{
|
|
341
|
+
return this.rootComponent.worldToLocal(vec);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
localToWorld(vec:Vector3):Vector3
|
|
345
|
+
{
|
|
346
|
+
return this.rootComponent.localToWorld(vec);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
getComponents()
|
|
350
|
+
{
|
|
351
|
+
return this.rootComponent.childrenComponents;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
addComponent(newComponent:SceneComponent, attachmentRule:AttachmentRules = AttachmentRules.KeepRelative)
|
|
355
|
+
{
|
|
356
|
+
this.rootComponent.addChildComponent(newComponent, attachmentRule);
|
|
357
|
+
if (this._world)
|
|
358
|
+
{
|
|
359
|
+
newComponent.onAddedToWorld(this._world);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
removeComponent(targetComponent:SceneComponent)
|
|
364
|
+
{
|
|
365
|
+
if (targetComponent === this._rootComponent)
|
|
366
|
+
{
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.rootComponent.removeChildComponent(targetComponent);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
clearComponent()
|
|
373
|
+
{
|
|
374
|
+
this.rootComponent.destroyChildren();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
addChildActor(newActor:Actor, attachmentRule:AttachmentRules = AttachmentRules.KeepWorld)
|
|
378
|
+
{
|
|
379
|
+
if (!(newActor.rootComponent))
|
|
380
|
+
{
|
|
381
|
+
console.error("Actor :: addChildActor : the 'newActor' you want to add has no rootcomponent");
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (newActor.parentActor === this)
|
|
385
|
+
{
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (attachmentRule === AttachmentRules.KeepRelative)
|
|
389
|
+
{
|
|
390
|
+
this.rootComponent.attachComponent(newActor.rootComponent);
|
|
391
|
+
}
|
|
392
|
+
if (attachmentRule === AttachmentRules.KeepWorld)
|
|
393
|
+
{
|
|
394
|
+
let worldMatrix = newActor.getWorldMatrix();
|
|
395
|
+
this.rootComponent.attachComponent(newActor.rootComponent);
|
|
396
|
+
newActor.setWorldMatrix(worldMatrix);
|
|
397
|
+
}
|
|
398
|
+
if (this._world)
|
|
399
|
+
{
|
|
400
|
+
this._world.viewport.markRenderStateDirty();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
removeChildActor(target:Actor)
|
|
405
|
+
{
|
|
406
|
+
let worldMatrix = target.getWorldMatrix();
|
|
407
|
+
this.rootComponent.detachComponent(target.rootComponent);
|
|
408
|
+
target.setWorldMatrix(worldMatrix);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
removeFromParent()
|
|
412
|
+
{
|
|
413
|
+
if (this.parentActor)
|
|
414
|
+
{
|
|
415
|
+
this.parentActor.removeChildActor(this);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
onAddedToWorld(world:World)
|
|
420
|
+
{
|
|
421
|
+
this._world = world;
|
|
422
|
+
|
|
423
|
+
this.rootComponent.onAddedToWorld(this._world);
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
this.childActors.forEach((elem) =>
|
|
427
|
+
{
|
|
428
|
+
elem.onAddedToWorld(world);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
onRemovedFromWorld()
|
|
433
|
+
{
|
|
434
|
+
this._world = null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
get isHoverEnabled()
|
|
439
|
+
{
|
|
440
|
+
return this.rootComponent.isHoverEnabled;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
set isHoverEnabled(bCanHorver:boolean)
|
|
444
|
+
{
|
|
445
|
+
this.rootComponent.isHoverEnabled = bCanHorver;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
get isClickEnabled()
|
|
449
|
+
{
|
|
450
|
+
return this.rootComponent.isClickEnabled;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
set isClickEnabled(bCanHorver)
|
|
454
|
+
{
|
|
455
|
+
this.rootComponent.isClickEnabled = bCanHorver;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// hovering begin
|
|
459
|
+
addHoveringBeginEvent(newFunc:(component?:SceneComponent)=>void)
|
|
460
|
+
{
|
|
461
|
+
this.onHoverBeginEvent.push(newFunc);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
removeHoveringBeginEvent(target:(component?:SceneComponent)=>void)
|
|
465
|
+
{
|
|
466
|
+
let index = this.onHoverBeginEvent.indexOf(target);
|
|
467
|
+
if (index >= 0)
|
|
468
|
+
{
|
|
469
|
+
this.onHoverBeginEvent.splice(index, 1);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
clearHoveringBeginEvent()
|
|
474
|
+
{
|
|
475
|
+
this.onHoverBeginEvent = [];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
onComponentHorveringBegin(component:SceneComponent)
|
|
479
|
+
{
|
|
480
|
+
for (let i = 0; i < this.onHoverBeginEvent.length; ++i)
|
|
481
|
+
{
|
|
482
|
+
this.onHoverBeginEvent[i](component);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// hovering end
|
|
487
|
+
addHoveringEndEvent(newFunc:(component?:SceneComponent)=>void)
|
|
488
|
+
{
|
|
489
|
+
this.onHoverEndEvent.push(newFunc);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
removeHoveringEndEvent(target:(component?:SceneComponent)=>void)
|
|
493
|
+
{
|
|
494
|
+
let index = this.onHoverEndEvent.indexOf(target);
|
|
495
|
+
if (index >= 0)
|
|
496
|
+
{
|
|
497
|
+
this.onHoverEndEvent.splice(index, 1);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
clearHoveringEndEvent()
|
|
502
|
+
{
|
|
503
|
+
this.onHoverEndEvent = [];
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
onComponentHorveringEnd(component:SceneComponent)
|
|
507
|
+
{
|
|
508
|
+
// console.log("onComponentHorveringEnd", this)
|
|
509
|
+
for (let i = 0; i < this.onHoverEndEvent.length; ++i)
|
|
510
|
+
{
|
|
511
|
+
this.onHoverEndEvent[i](component);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
//click
|
|
516
|
+
addClickEvent(newFunc:(component?:SceneComponent)=>void)
|
|
517
|
+
{
|
|
518
|
+
this.onClickedEvent.push(newFunc);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
removeClickEvent(target:(component?:SceneComponent)=>void)
|
|
522
|
+
{
|
|
523
|
+
let index = this.onClickedEvent.indexOf(target);
|
|
524
|
+
if (index >= 0)
|
|
525
|
+
{
|
|
526
|
+
this.onClickedEvent.splice(index, 1);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
clearClickEvent()
|
|
531
|
+
{
|
|
532
|
+
this.onClickedEvent = [];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
onComponentClicked(component:SceneComponent)
|
|
536
|
+
{
|
|
537
|
+
//console.log("onComponentClicked", this.Name, component)
|
|
538
|
+
for (let i = 0; i < this.onClickedEvent.length; ++i)
|
|
539
|
+
{
|
|
540
|
+
this.onClickedEvent[i](component);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// double click
|
|
545
|
+
addDoubleClickEvent(newFunc:(component?:SceneComponent)=>void)
|
|
546
|
+
{
|
|
547
|
+
this.onDoubleClickedEvent.push(newFunc);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
removeDoubleClickEvent(target:(component?:SceneComponent)=>void)
|
|
551
|
+
{
|
|
552
|
+
let index = this.onClickedEvent.indexOf(target);
|
|
553
|
+
if (index >= 0)
|
|
554
|
+
{
|
|
555
|
+
this.onDoubleClickedEvent.splice(index, 1);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
onComponentDoubleClicked(component:SceneComponent)
|
|
559
|
+
{
|
|
560
|
+
//console.log("onComponentClicked", this.Name, component)
|
|
561
|
+
for (let i = 0; i < this.onDoubleClickedEvent.length; ++i)
|
|
562
|
+
{
|
|
563
|
+
this.onDoubleClickedEvent[i](component);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
clearDoubleClickEvent()
|
|
568
|
+
{
|
|
569
|
+
this.onDoubleClickedEvent = [];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
import {ColorRepresentation} from "three";
|
|
3
|
+
import {Actor} from "../../Actor.ts";
|
|
4
|
+
import {DirectionalLightComponent} from "../../Components/Light/DirectionalLight/DirectionalLightComponent.ts";
|
|
5
|
+
|
|
6
|
+
export class DirectionalLightActor extends Actor
|
|
7
|
+
{
|
|
8
|
+
protected lightComponent : DirectionalLightComponent
|
|
9
|
+
constructor(color:ColorRepresentation = 0xffffff, intensity:number = 1)
|
|
10
|
+
{
|
|
11
|
+
super();
|
|
12
|
+
this.lightComponent = new DirectionalLightComponent(color, intensity)
|
|
13
|
+
this.rootComponent = this.lightComponent
|
|
14
|
+
this.lightComponent.castShadow = true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import {Material, MeshBasicMaterial} from "three";
|
|
3
|
+
import {Actor} from "../../Actor.ts";
|
|
4
|
+
import {BoxComponent} from "../../Components/Mesh/Shape/BoxComponent.ts";
|
|
5
|
+
|
|
6
|
+
export class BoxActor extends Actor
|
|
7
|
+
{
|
|
8
|
+
constructor(
|
|
9
|
+
width :number = 1,
|
|
10
|
+
height :number = 1,
|
|
11
|
+
depth :number = 1,
|
|
12
|
+
widthSegments :number = 1,
|
|
13
|
+
heightSegments:number = 1,
|
|
14
|
+
depthSegments :number = 1,
|
|
15
|
+
material :Material = new MeshBasicMaterial())
|
|
16
|
+
{
|
|
17
|
+
super();
|
|
18
|
+
this.addComponent(new BoxComponent(width, height, depth, widthSegments,heightSegments,depthSegments, material))
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// import {CurveMaterial, LYBaseActor, LYCurveComponent} from "../../../../LYCustomFrame";
|
|
2
|
+
// import {Vector3} from "three";
|
|
3
|
+
// import { MeshLineMaterial } from 'three.meshline';
|
|
4
|
+
// export class LYCurveActor extends LYBaseActor
|
|
5
|
+
// {
|
|
6
|
+
// constructor(points:Vector3[] = [], material:MeshLineMaterial = CurveMaterial, tension:number = 0)
|
|
7
|
+
// {
|
|
8
|
+
// super();
|
|
9
|
+
// this.addComponent(new LYCurveComponent(points, material, tension))
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
import {Material, MeshBasicMaterial} from "three";
|
|
3
|
+
import {Actor} from "../../Actor.ts";
|
|
4
|
+
import {PlaneComponent} from "../../Components/Mesh/Shape/PlaneComponent.ts";
|
|
5
|
+
|
|
6
|
+
export class PlaneActor extends Actor
|
|
7
|
+
{
|
|
8
|
+
get planeComponent(): PlaneComponent | null
|
|
9
|
+
{
|
|
10
|
+
return this._planeComponent;
|
|
11
|
+
}
|
|
12
|
+
private _planeComponent: PlaneComponent|null;
|
|
13
|
+
constructor(width:number, height:number, material:Material = new MeshBasicMaterial(), widthSegments:number = 1, heightSegments:number = 1)
|
|
14
|
+
{
|
|
15
|
+
super();
|
|
16
|
+
this._planeComponent = new PlaneComponent(width, height, material, widthSegments,heightSegments )
|
|
17
|
+
this._planeComponent.setRotation(Math.PI * 0.5 * -1 , 0,0)
|
|
18
|
+
this.addComponent(this._planeComponent)
|
|
19
|
+
this._planeComponent.receiveShadow = true
|
|
20
|
+
}
|
|
21
|
+
destroy()
|
|
22
|
+
{
|
|
23
|
+
this._planeComponent?.destroy()
|
|
24
|
+
this._planeComponent = null
|
|
25
|
+
super.destroy();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import {Material, MeshBasicMaterial} from "three";
|
|
3
|
+
import {Actor} from "../../Actor.ts";
|
|
4
|
+
|
|
5
|
+
export class LYTubeActor extends Actor
|
|
6
|
+
{
|
|
7
|
+
constructor(width:number = 1, height:number = 1, depth:number = 1, material:Material = new MeshBasicMaterial())
|
|
8
|
+
{
|
|
9
|
+
// const points = [{
|
|
10
|
+
// x: 0,
|
|
11
|
+
// y: 0,
|
|
12
|
+
// z: 0
|
|
13
|
+
// },
|
|
14
|
+
// {
|
|
15
|
+
// x: 100,
|
|
16
|
+
// y: 0,
|
|
17
|
+
// z: 0
|
|
18
|
+
// },
|
|
19
|
+
// {
|
|
20
|
+
// x: 100,
|
|
21
|
+
// y: 0,
|
|
22
|
+
// z: 200
|
|
23
|
+
// },
|
|
24
|
+
// ];
|
|
25
|
+
//
|
|
26
|
+
// const path = createPath(points);
|
|
27
|
+
//
|
|
28
|
+
// const pipeGeometry = new TubeGeometry(path, 256, radius, 64);
|
|
29
|
+
// const pipeMaterial = new MeshPhongMaterial({
|
|
30
|
+
// color
|
|
31
|
+
// });
|
|
32
|
+
// const pipe = new Mesh(pipeGeometry, pipeMaterial);
|
|
33
|
+
//
|
|
34
|
+
// super();
|
|
35
|
+
// this.addComponent(new LYBoxComponent(width, height, depth, material))
|
|
36
|
+
}
|
|
37
|
+
}
|