lythreeframe 1.0.2 → 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/LICENSE +8 -0
- package/README.md +3 -0
- package/dist/bundle.cjs.js +2646 -0
- package/dist/bundle.esm.js +2612 -0
- package/dist/index.d.ts +40 -0
- 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 +31 -13
- package/index.js +0 -48
- package/src/AssetManagement/AssetDefines.ts +0 -8
- package/src/AssetManagement/AssetManager.ts +0 -286
- package/src/AssetManagement/AssetPointer/AssetPointer.ts +0 -41
- package/src/AssetManagement/Task/Task.ts +0 -24
- package/src/Container/SmartPointer.ts +0 -54
- package/src/Defines.ts +0 -11
- package/src/Delegate.ts +0 -37
- package/src/Factory/CameraFactory.ts +0 -81
- package/src/Factory/RendererFactory.ts +0 -7
- package/src/Frame/Controller.ts +0 -261
- package/src/Frame/Viewport.ts +0 -516
- package/src/Frame/World.ts +0 -59
- package/src/Frame.ts +0 -511
- package/src/Geometry/PlaneGeometry.ts +0 -53
- package/src/Geometry/TriangleGeometry.ts +0 -50
- package/src/Library/ContainerLibrary.ts +0 -21
- package/src/Library/MaterialLibrary.ts +0 -288
- package/src/Library/Math.ts +0 -154
- package/src/Library/ResourceLibrary.ts +0 -21
- package/src/Object/Actor.ts +0 -571
- package/src/Object/Actors/Camera/CameraActor.ts +0 -11
- package/src/Object/Actors/Light/DirectionalLightActor.ts +0 -18
- package/src/Object/Actors/Shape/BoxActor.ts +0 -20
- package/src/Object/Actors/Shape/CurveActor.ts +0 -11
- package/src/Object/Actors/Shape/PlaneActor.ts +0 -27
- package/src/Object/Actors/Shape/TubeActor.ts +0 -37
- package/src/Object/BaseObject.ts +0 -45
- package/src/Object/Components/2D/2DComponent.ts +0 -64
- package/src/Object/Components/Camera/CameraComponent.ts +0 -113
- package/src/Object/Components/Component.ts +0 -67
- package/src/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts +0 -78
- package/src/Object/Components/Light/LightComponent.ts +0 -54
- package/src/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.ts +0 -39
- package/src/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.ts +0 -115
- package/src/Object/Components/Mesh/Line/CurveComponent.ts +0 -221
- package/src/Object/Components/Mesh/MeshComponent.ts +0 -162
- package/src/Object/Components/Mesh/Shape/BoxComponent.ts +0 -17
- package/src/Object/Components/Mesh/Shape/PlaneComponent.ts +0 -10
- package/src/Object/Components/Mesh/Shape/SphereComponent.ts +0 -10
- package/src/Object/Components/Mesh/Sprite/SpriteComponent.ts +0 -32
- package/src/Object/Components/SceneComponent.ts +0 -809
- package/src/Object/Controller/Controller.ts +0 -764
- package/src/Object/Pawn/CameraStatus.ts +0 -262
- package/src/Object/Pawn/FirstPerson.ts +0 -230
- package/src/Object/Pawn/Oribital.ts +0 -276
- package/src/Object/Pawn/PawnBase.ts +0 -189
- package/src/Object/Pawn/TopView.ts +0 -205
- package/src/Object/Pawn/TransformControl.ts +0 -215
- package/src/Object/Pawn/staticCamera.ts +0 -80
- package/src/Object/PawnV2/FirstPerson.ts +0 -12
- package/src/Object/PawnV2/Oribital.ts +0 -45
- package/src/Object/PawnV2/Pawn.ts +0 -50
- package/src/Object/PawnV2/TransformControl.ts +0 -201
- package/src/PostProcess/Param/Bloom.ts +0 -12
- package/src/PostProcess/Param/DOF.ts +0 -14
- package/src/PostProcess/Param/Denoise.ts +0 -14
- package/src/PostProcess/Param/GTAO.ts +0 -21
- package/src/PostProcess/Param/LensFlare.ts +0 -11
- package/src/PostProcess/Param/MotionBlur.ts +0 -8
- package/src/PostProcess/Param/Outline.ts +0 -20
- package/src/PostProcess/Param/SSR.ts +0 -11
- package/src/PostProcess/Param/ToneMapping.ts +0 -31
- package/src/PostProcess/PostProcessParam.ts +0 -26
- package/src/PostProcess/WebGPUPostProcessFactory.ts +0 -217
- package/src/Shader/Postprocess/ColorShader.ts +0 -49
- package/src/ThreeJsApp.ts +0 -124
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import {BufferGeometry, FileLoader, LoadingManager, Material, Mesh, Texture,} from 'three';
|
|
2
|
-
import {MeshComponent} from "../Object/Components/Mesh/MeshComponent";
|
|
3
|
-
import {SceneComponent} from "../Object/Components/SceneComponent.ts";
|
|
4
|
-
import {LYLoadTask} from "./Task/Task.ts";
|
|
5
|
-
import {TAssetPointer} from "./AssetPointer/AssetPointer.ts";
|
|
6
|
-
import { DRACOLoader, GLTF, GLTFLoader } from 'three/examples/jsm/Addons.js';
|
|
7
|
-
|
|
8
|
-
// this class should be a singleton
|
|
9
|
-
export class LYAssetManager
|
|
10
|
-
{
|
|
11
|
-
protected assetPointer:Map<string, TAssetPointer<BufferGeometry | Texture | Material>> = new Map();
|
|
12
|
-
protected readonly dracoLoader:DRACOLoader;
|
|
13
|
-
protected readonly gltfLoader:GLTFLoader;
|
|
14
|
-
protected readonly loadingManager:LoadingManager;
|
|
15
|
-
|
|
16
|
-
constructor()
|
|
17
|
-
{
|
|
18
|
-
this.dracoLoader = new DRACOLoader();
|
|
19
|
-
this.dracoLoader.setDecoderPath(`./SceneResource/draco/`);
|
|
20
|
-
this.dracoLoader.setDecoderConfig({type:"js"});
|
|
21
|
-
this.dracoLoader.preload();
|
|
22
|
-
|
|
23
|
-
this.loadingManager = new LoadingManager();
|
|
24
|
-
|
|
25
|
-
this.gltfLoader = new GLTFLoader(this.loadingManager);
|
|
26
|
-
this.gltfLoader.setDRACOLoader(this.dracoLoader);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get LoadingManager():LoadingManager
|
|
30
|
-
{
|
|
31
|
-
return this.loadingManager;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static Get()
|
|
35
|
-
{
|
|
36
|
-
return assetManager;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static ClearAssets()
|
|
40
|
-
{
|
|
41
|
-
assetManager.clearAssets();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
convertThreeObjectToLYObject(parentLYComponent:SceneComponent, threejsObject:any):SceneComponent | null
|
|
45
|
-
{
|
|
46
|
-
let location = threejsObject.position.clone();
|
|
47
|
-
let rotation = threejsObject.rotation.clone();
|
|
48
|
-
let scale = threejsObject.scale.clone();
|
|
49
|
-
|
|
50
|
-
let newComp = null;
|
|
51
|
-
let children = threejsObject.children;
|
|
52
|
-
threejsObject.children = [];
|
|
53
|
-
if (threejsObject.type === "Group" || threejsObject.type === "Object3D")
|
|
54
|
-
{
|
|
55
|
-
newComp = new SceneComponent(threejsObject);
|
|
56
|
-
}
|
|
57
|
-
else if (threejsObject.isMesh)
|
|
58
|
-
{
|
|
59
|
-
let obj = threejsObject as Mesh;
|
|
60
|
-
newComp = new MeshComponent(obj);
|
|
61
|
-
// assetManager.#collectMatAndGeoInMesh(threejsObject)
|
|
62
|
-
threejsObject.layers.set(0);
|
|
63
|
-
}
|
|
64
|
-
else
|
|
65
|
-
{
|
|
66
|
-
newComp = new SceneComponent(threejsObject);
|
|
67
|
-
}
|
|
68
|
-
if (newComp === null)
|
|
69
|
-
{
|
|
70
|
-
threejsObject.children = children;
|
|
71
|
-
//threejsObject.parent = parent
|
|
72
|
-
console.log("Unprocess", threejsObject);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
parentLYComponent.addChildComponent(newComp);
|
|
76
|
-
|
|
77
|
-
newComp.setPosition(location);
|
|
78
|
-
newComp.setRotation(rotation);
|
|
79
|
-
newComp.setScale(scale);
|
|
80
|
-
for (let i = 0; i < children.length; ++i)
|
|
81
|
-
{
|
|
82
|
-
this.convertThreeObjectToLYObject(newComp, children[i]);
|
|
83
|
-
}
|
|
84
|
-
return threejsObject.userData.LYObject;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private collectResourcesAndReferences(gltf:GLTF)
|
|
88
|
-
{
|
|
89
|
-
function countResource(map:Map<any, number>, resource:any)
|
|
90
|
-
{
|
|
91
|
-
if (!map.has(resource))
|
|
92
|
-
{
|
|
93
|
-
map.set(resource, 1);
|
|
94
|
-
}
|
|
95
|
-
else
|
|
96
|
-
{
|
|
97
|
-
map.set(resource, map.get(resource)! + 1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const resources = {
|
|
102
|
-
geometries:new Map<BufferGeometry, number>(),
|
|
103
|
-
materials :new Map<Material, number>(),
|
|
104
|
-
textures :new Map<Texture, number>()
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
gltf.scene.traverse((child:any) =>
|
|
109
|
-
{
|
|
110
|
-
if (child.geometry && child.geometry instanceof BufferGeometry)
|
|
111
|
-
{
|
|
112
|
-
countResource(resources.geometries, child.geometry);
|
|
113
|
-
}
|
|
114
|
-
if (child.material)
|
|
115
|
-
{
|
|
116
|
-
const mats = Array.isArray(child.material) ? child.material : [child.material];
|
|
117
|
-
mats.forEach((mat:Material|null) =>
|
|
118
|
-
{
|
|
119
|
-
if (mat)
|
|
120
|
-
{
|
|
121
|
-
countResource(resources.materials, mat);
|
|
122
|
-
Object.entries(mat).forEach(([key, value]) =>
|
|
123
|
-
{
|
|
124
|
-
if (value instanceof Texture)
|
|
125
|
-
{
|
|
126
|
-
countResource(resources.textures, value);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
function createPointer(manager:LYAssetManager, map:Map<BufferGeometry | Material | Texture, number>)
|
|
136
|
-
{
|
|
137
|
-
map.forEach((value, key:BufferGeometry | Material | Texture) =>
|
|
138
|
-
{
|
|
139
|
-
manager.addAsset(key, value);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
createPointer(this, resources.geometries);
|
|
144
|
-
createPointer(this, resources.materials);
|
|
145
|
-
createPointer(this, resources.textures);
|
|
146
|
-
|
|
147
|
-
// console.log('Geometries:', Array.from(resources.geometries.entries()));
|
|
148
|
-
// console.log('Materials:', Array.from(resources.materials.entries()));
|
|
149
|
-
// console.log('Textures:', Array.from(resources.textures.entries()));
|
|
150
|
-
// console.log('assetPointer:', this.assetPointer);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public checkMeshResource(mesh:Mesh)
|
|
154
|
-
{
|
|
155
|
-
if(mesh.geometry)
|
|
156
|
-
{
|
|
157
|
-
if(!mesh.geometry.userData["assetPointer"])
|
|
158
|
-
{
|
|
159
|
-
this.addAsset(mesh.geometry)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if(mesh.material)
|
|
164
|
-
{
|
|
165
|
-
const mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
166
|
-
mats.forEach((material) => {
|
|
167
|
-
if (material)
|
|
168
|
-
{
|
|
169
|
-
if(!material.userData["assetPointer"])
|
|
170
|
-
{
|
|
171
|
-
this.addAsset(material)
|
|
172
|
-
}
|
|
173
|
-
Object.entries(material).forEach(([key, value]) => {
|
|
174
|
-
if (value instanceof Texture)
|
|
175
|
-
{
|
|
176
|
-
if(!value.userData["assetPointer"])
|
|
177
|
-
{
|
|
178
|
-
this.addAsset(value)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
loadMultiGLTFAsGroup(tasks:LYLoadTask[], onProgress:((url:string, loaded:number, total:number) => void) | null = null, onAllFinished:(() => void) | null = null)
|
|
188
|
-
{
|
|
189
|
-
this.loadingManager.onLoad = onAllFinished ? () =>
|
|
190
|
-
{
|
|
191
|
-
this.loadingManager.onLoad = () =>
|
|
192
|
-
{
|
|
193
|
-
};
|
|
194
|
-
onAllFinished();
|
|
195
|
-
} : () =>
|
|
196
|
-
{
|
|
197
|
-
this.loadingManager.onLoad = () =>
|
|
198
|
-
{
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
this.loadingManager.onProgress = onProgress ? (url, loaded, total) =>
|
|
202
|
-
{
|
|
203
|
-
onProgress(url, loaded, total);
|
|
204
|
-
} : () =>
|
|
205
|
-
{
|
|
206
|
-
};
|
|
207
|
-
tasks.forEach(
|
|
208
|
-
(task) =>
|
|
209
|
-
{
|
|
210
|
-
task.Paths.forEach(
|
|
211
|
-
(path) =>
|
|
212
|
-
{
|
|
213
|
-
const onGlbLoaded = (glb:GLTF) =>
|
|
214
|
-
{
|
|
215
|
-
task.onLoadingFinished(glb);
|
|
216
|
-
this.collectResourcesAndReferences(glb);
|
|
217
|
-
};
|
|
218
|
-
try
|
|
219
|
-
{
|
|
220
|
-
this.gltfLoader.load(path, (glb:GLTF) =>
|
|
221
|
-
{
|
|
222
|
-
onGlbLoaded(glb);
|
|
223
|
-
});
|
|
224
|
-
} catch (e)
|
|
225
|
-
{
|
|
226
|
-
console.error(e, path);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
loadFile(filepath = '', onLoadFinished:(data:any)=>void)
|
|
234
|
-
{
|
|
235
|
-
const loader = new FileLoader();
|
|
236
|
-
loader.load(filepath, (data) =>
|
|
237
|
-
{
|
|
238
|
-
onLoadFinished(data);
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
addAsset(asset:BufferGeometry | Material | Texture, referenceCount:number = 1)
|
|
243
|
-
{
|
|
244
|
-
let pointer:TAssetPointer<BufferGeometry | Material | Texture> | null = null;
|
|
245
|
-
if (!asset.userData["assetPointer"])
|
|
246
|
-
{
|
|
247
|
-
pointer = new TAssetPointer(asset, referenceCount);
|
|
248
|
-
asset.userData["assetPointer"] = pointer;
|
|
249
|
-
}
|
|
250
|
-
else
|
|
251
|
-
{
|
|
252
|
-
pointer = asset.userData["assetPointer"] as TAssetPointer<BufferGeometry | Material | Texture>;
|
|
253
|
-
pointer.addRef(referenceCount);
|
|
254
|
-
}
|
|
255
|
-
if (pointer)
|
|
256
|
-
{
|
|
257
|
-
this.assetPointer.set(pointer.uuid, pointer);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
releaseAsset(asset:BufferGeometry | Material | Texture)
|
|
262
|
-
{
|
|
263
|
-
// let uuid = asset.uuid
|
|
264
|
-
let p = asset.userData["assetPointer"] as TAssetPointer<BufferGeometry | Material | Texture>;
|
|
265
|
-
if (p)
|
|
266
|
-
{
|
|
267
|
-
p.release();
|
|
268
|
-
}
|
|
269
|
-
else
|
|
270
|
-
{
|
|
271
|
-
asset.dispose();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
clearAssets()
|
|
276
|
-
{
|
|
277
|
-
let pointers = Array.from(this.assetPointer.values());
|
|
278
|
-
pointers.forEach((p) =>
|
|
279
|
-
{
|
|
280
|
-
p.forceRelease();
|
|
281
|
-
});
|
|
282
|
-
this.assetPointer.clear();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
let assetManager = new LYAssetManager();
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {BufferGeometry, Material, Texture} from "three";
|
|
3
|
-
import {TSmartPointer} from "../../Container/SmartPointer.ts";
|
|
4
|
-
|
|
5
|
-
export class TAssetPointer<T extends BufferGeometry|Texture|Material> extends TSmartPointer<T>
|
|
6
|
-
{
|
|
7
|
-
get uuid():string
|
|
8
|
-
{
|
|
9
|
-
return this._uuid;
|
|
10
|
-
}
|
|
11
|
-
private readonly _uuid:string
|
|
12
|
-
constructor(value: T, referenceCount:number = 1)
|
|
13
|
-
{
|
|
14
|
-
super(value,referenceCount);
|
|
15
|
-
this._uuid = value.uuid
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override release():void
|
|
19
|
-
{
|
|
20
|
-
if (this.value !== null)
|
|
21
|
-
{
|
|
22
|
-
this.referenceCount--;
|
|
23
|
-
|
|
24
|
-
if (this.referenceCount === 0)
|
|
25
|
-
{
|
|
26
|
-
this.value.dispose();
|
|
27
|
-
this.value = null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
forceRelease()
|
|
33
|
-
{
|
|
34
|
-
if (this.value !== null)
|
|
35
|
-
{
|
|
36
|
-
this.value.dispose();
|
|
37
|
-
this.value = null
|
|
38
|
-
this.referenceCount = 0
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export class LYLoadTask
|
|
2
|
-
{
|
|
3
|
-
private readonly paths : string[]
|
|
4
|
-
private readonly onLoaded : (loaded:any)=>void | null
|
|
5
|
-
|
|
6
|
-
constructor(paths:string[], onLoaded:(loaded:any)=>void )
|
|
7
|
-
{
|
|
8
|
-
this.paths = paths;
|
|
9
|
-
this.onLoaded = onLoaded;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get Paths()
|
|
13
|
-
{
|
|
14
|
-
return this.paths
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
onLoadingFinished(loaded:any)
|
|
18
|
-
{
|
|
19
|
-
if (this.onLoaded)
|
|
20
|
-
{
|
|
21
|
-
this.onLoaded(loaded)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export class TSmartPointer<T>
|
|
3
|
-
{
|
|
4
|
-
protected referenceCount:number = 1;
|
|
5
|
-
protected value:T | null = null;
|
|
6
|
-
|
|
7
|
-
constructor(value:T, referenceCount:number = 1)
|
|
8
|
-
{
|
|
9
|
-
this.value = value;
|
|
10
|
-
this.referenceCount = referenceCount;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getRefCount():number
|
|
14
|
-
{
|
|
15
|
-
return this.referenceCount;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
addRef(count:number = 1):void
|
|
19
|
-
{
|
|
20
|
-
if (this.value !== null)
|
|
21
|
-
{
|
|
22
|
-
this.referenceCount+=count;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
release():void
|
|
27
|
-
{
|
|
28
|
-
if (this.value !== null)
|
|
29
|
-
{
|
|
30
|
-
this.referenceCount--;
|
|
31
|
-
console.log(`Reference count decreased to: ${this.referenceCount}`);
|
|
32
|
-
|
|
33
|
-
if (this.referenceCount === 0)
|
|
34
|
-
{
|
|
35
|
-
console.log("No more references. Deleting object.");
|
|
36
|
-
this.value = null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
forceRelease()
|
|
42
|
-
{
|
|
43
|
-
if (this.value !== null)
|
|
44
|
-
{
|
|
45
|
-
this.value = null
|
|
46
|
-
this.referenceCount = 0
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getValue():T | null
|
|
51
|
-
{
|
|
52
|
-
return this.value;
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/Defines.ts
DELETED
package/src/Delegate.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class Delegate<T extends any[]>
|
|
2
|
-
{
|
|
3
|
-
private functions:Array<(...args:T) => void>;
|
|
4
|
-
|
|
5
|
-
constructor()
|
|
6
|
-
{
|
|
7
|
-
this.functions = [];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
broadcast(...args:T):void
|
|
11
|
-
{
|
|
12
|
-
this.functions.forEach((func) => func(...args));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
add(func:(...args:T) => void):void
|
|
16
|
-
{
|
|
17
|
-
this.functions.push(func);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
remove(func:(...args:T) => void):void
|
|
21
|
-
{
|
|
22
|
-
const index = this.functions.indexOf(func);
|
|
23
|
-
if (index >= 0)
|
|
24
|
-
{
|
|
25
|
-
this.functions.splice(index, 1);
|
|
26
|
-
}
|
|
27
|
-
else
|
|
28
|
-
{
|
|
29
|
-
console.warn("function not found");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
clear():void
|
|
34
|
-
{
|
|
35
|
-
this.functions = [];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {OrthographicCamera, PerspectiveCamera} from "three";
|
|
2
|
-
|
|
3
|
-
export interface CameraParam
|
|
4
|
-
{
|
|
5
|
-
near:number,
|
|
6
|
-
far:number,
|
|
7
|
-
param:PerspectiveCameraParam | OrthographicCameraParam
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface PerspectiveCameraParam
|
|
11
|
-
{
|
|
12
|
-
fov:number,
|
|
13
|
-
aspect:number,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface OrthographicCameraParam
|
|
17
|
-
{
|
|
18
|
-
left:number,
|
|
19
|
-
right:number,
|
|
20
|
-
top:number,
|
|
21
|
-
bottom:number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class CameraFactory
|
|
25
|
-
{
|
|
26
|
-
static createCamera(param:CameraParam)
|
|
27
|
-
{
|
|
28
|
-
let cam:PerspectiveCamera | OrthographicCamera | null = null;
|
|
29
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
30
|
-
{
|
|
31
|
-
cam = new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
32
|
-
}
|
|
33
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
34
|
-
{
|
|
35
|
-
cam = new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
36
|
-
}
|
|
37
|
-
if (!cam)
|
|
38
|
-
{
|
|
39
|
-
console.error("create camera failed");
|
|
40
|
-
debugger
|
|
41
|
-
throw Error("create camera failed");
|
|
42
|
-
}
|
|
43
|
-
return cam
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static updataCamera(param:CameraParam, camera:PerspectiveCamera | OrthographicCamera)
|
|
47
|
-
{
|
|
48
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
49
|
-
{
|
|
50
|
-
if (camera instanceof PerspectiveCamera)
|
|
51
|
-
{
|
|
52
|
-
camera.near = param.near;
|
|
53
|
-
camera.far = param.far;
|
|
54
|
-
camera.fov = param.param.fov;
|
|
55
|
-
camera.aspect = param.param.aspect;
|
|
56
|
-
return camera
|
|
57
|
-
}
|
|
58
|
-
else
|
|
59
|
-
{
|
|
60
|
-
return new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
64
|
-
{
|
|
65
|
-
if (camera instanceof OrthographicCamera)
|
|
66
|
-
{
|
|
67
|
-
camera.near = param.near;
|
|
68
|
-
camera.far = param.far;
|
|
69
|
-
camera.left = param.param.left;
|
|
70
|
-
camera.right = param.param.right;
|
|
71
|
-
camera.top = param.param.top;
|
|
72
|
-
camera.bottom = param.param.bottom;
|
|
73
|
-
return camera
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
{
|
|
77
|
-
return new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|