@relu-interactives/spatial-ecs 0.2.5 → 0.2.7
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/{Video-DCMCLInA.d.ts → Video-B-qMljTn.d.ts} +15 -7
- package/dist/{Video-ChVFs9Tl.d.cts → Video-Dj4KBqQ1.d.cts} +15 -7
- package/dist/{chunk-RXCUHGRB.js → chunk-2F6T3BVO.js} +193 -33
- package/dist/chunk-2F6T3BVO.js.map +1 -0
- package/dist/{chunk-4A66FSFT.js → chunk-EIC5B3A7.js} +4 -4
- package/dist/{chunk-4A66FSFT.js.map → chunk-EIC5B3A7.js.map} +1 -1
- package/dist/{chunk-CRP3W2GK.js → chunk-FDWNCXU3.js} +3 -3
- package/dist/{chunk-CRP3W2GK.js.map → chunk-FDWNCXU3.js.map} +1 -1
- package/dist/{chunk-NB6I5JJN.js → chunk-G2DUXNTQ.js} +3 -2
- package/dist/chunk-G2DUXNTQ.js.map +1 -0
- package/dist/{chunk-KRZLEPRI.js → chunk-R5D5PWXV.js} +6 -2
- package/dist/chunk-R5D5PWXV.js.map +1 -0
- package/dist/components/index.cjs +4 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +4 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +1 -1
- package/dist/factories/index.d.ts +1 -1
- package/dist/factories/index.js +3 -3
- package/dist/{index-D1I5L7bA.d.cts → index-B12sx9yF.d.cts} +1 -1
- package/dist/{index-DGZDgt3p.d.ts → index-Cf-PaKyN.d.ts} +1 -1
- package/dist/index.cjs +197 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +193 -29
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +17 -4
- package/dist/systems/index.d.ts +17 -4
- package/dist/systems/index.js +3 -3
- package/dist/worldSnapshotUtils.cjs +1 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -1
- package/dist/worldSnapshotUtils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KRZLEPRI.js.map +0 -1
- package/dist/chunk-NB6I5JJN.js.map +0 -1
- package/dist/chunk-RXCUHGRB.js.map +0 -1
|
@@ -647,11 +647,11 @@ type InstanceTransform = {
|
|
|
647
647
|
z: number;
|
|
648
648
|
};
|
|
649
649
|
};
|
|
650
|
-
/** Primitive geometry kinds supported by instanced mesh rendering. */
|
|
651
|
-
type InstancedMeshKind = "capsule" | "cube" | "cylinder" | "plane" | "sphere";
|
|
650
|
+
/** Primitive geometry kinds and custom 3D model kind supported by instanced mesh rendering. */
|
|
651
|
+
type InstancedMeshKind = "capsule" | "cube" | "cylinder" | "model" | "plane" | "sphere";
|
|
652
652
|
/** Default identity instance transform. */
|
|
653
653
|
declare const DEFAULT_INSTANCE_TRANSFORM: InstanceTransform;
|
|
654
|
-
/** Default geometry parameters per instanced mesh kind. */
|
|
654
|
+
/** Default geometry parameters per instanced mesh kind. For "model" kind, cube params are stored as a placeholder (unused). */
|
|
655
655
|
declare const DEFAULT_INSTANCED_MESH_PARAMETERS: Record<InstancedMeshKind, MeshGeometryParameters>;
|
|
656
656
|
/**
|
|
657
657
|
* Holds authored instanced-mesh data for an entity that renders as a
|
|
@@ -665,9 +665,14 @@ declare const DEFAULT_INSTANCED_MESH_PARAMETERS: Record<InstancedMeshKind, MeshG
|
|
|
665
665
|
* @category Components
|
|
666
666
|
*/
|
|
667
667
|
declare class InstancedMeshComponent extends Component {
|
|
668
|
-
/**
|
|
668
|
+
/** Geometry kind for all instances. Use `"model"` for a custom GLTF/GLB asset. */
|
|
669
669
|
meshKind: InstancedMeshKind;
|
|
670
|
-
/**
|
|
670
|
+
/**
|
|
671
|
+
* Path to the GLTF/GLB asset when `meshKind === "model"`.
|
|
672
|
+
* Serialized in snapshots and restored on hydration.
|
|
673
|
+
*/
|
|
674
|
+
modelPath: string;
|
|
675
|
+
/** Editable geometry parameters (width/height/depth, radius, etc.). Ignored when `meshKind === "model"`. */
|
|
671
676
|
meshParameters: MeshGeometryParameters;
|
|
672
677
|
/** Whether all instances cast shadows. */
|
|
673
678
|
castShadow: boolean;
|
|
@@ -676,14 +681,17 @@ declare class InstancedMeshComponent extends Component {
|
|
|
676
681
|
/** Per-instance transforms stored in local space relative to the anchor object. */
|
|
677
682
|
instances: InstanceTransform[];
|
|
678
683
|
/**
|
|
679
|
-
* Live
|
|
684
|
+
* Live runtime container managed by {@link InstancedMeshSystem}:
|
|
685
|
+
* - For primitive kinds: a `THREE.InstancedMesh`.
|
|
686
|
+
* - For `"model"` kind: a `THREE.Group` containing per-mesh `THREE.InstancedMesh` objects.
|
|
680
687
|
* Excluded from snapshot serialization — do **not** read this in hydration code.
|
|
681
688
|
*/
|
|
682
|
-
instancedMesh: THREE.
|
|
689
|
+
instancedMesh: THREE.Object3D | null;
|
|
683
690
|
constructor(meshKind?: InstancedMeshKind, meshParameters?: Partial<MeshGeometryParameters>, options?: {
|
|
684
691
|
castShadow?: boolean;
|
|
685
692
|
receiveShadow?: boolean;
|
|
686
693
|
instances?: InstanceTransform[];
|
|
694
|
+
modelPath?: string;
|
|
687
695
|
});
|
|
688
696
|
/** Sanitize and return a copy of the current mesh parameters with valid values. */
|
|
689
697
|
getSanitizedParameters(): MeshGeometryParameters;
|
|
@@ -647,11 +647,11 @@ type InstanceTransform = {
|
|
|
647
647
|
z: number;
|
|
648
648
|
};
|
|
649
649
|
};
|
|
650
|
-
/** Primitive geometry kinds supported by instanced mesh rendering. */
|
|
651
|
-
type InstancedMeshKind = "capsule" | "cube" | "cylinder" | "plane" | "sphere";
|
|
650
|
+
/** Primitive geometry kinds and custom 3D model kind supported by instanced mesh rendering. */
|
|
651
|
+
type InstancedMeshKind = "capsule" | "cube" | "cylinder" | "model" | "plane" | "sphere";
|
|
652
652
|
/** Default identity instance transform. */
|
|
653
653
|
declare const DEFAULT_INSTANCE_TRANSFORM: InstanceTransform;
|
|
654
|
-
/** Default geometry parameters per instanced mesh kind. */
|
|
654
|
+
/** Default geometry parameters per instanced mesh kind. For "model" kind, cube params are stored as a placeholder (unused). */
|
|
655
655
|
declare const DEFAULT_INSTANCED_MESH_PARAMETERS: Record<InstancedMeshKind, MeshGeometryParameters>;
|
|
656
656
|
/**
|
|
657
657
|
* Holds authored instanced-mesh data for an entity that renders as a
|
|
@@ -665,9 +665,14 @@ declare const DEFAULT_INSTANCED_MESH_PARAMETERS: Record<InstancedMeshKind, MeshG
|
|
|
665
665
|
* @category Components
|
|
666
666
|
*/
|
|
667
667
|
declare class InstancedMeshComponent extends Component {
|
|
668
|
-
/**
|
|
668
|
+
/** Geometry kind for all instances. Use `"model"` for a custom GLTF/GLB asset. */
|
|
669
669
|
meshKind: InstancedMeshKind;
|
|
670
|
-
/**
|
|
670
|
+
/**
|
|
671
|
+
* Path to the GLTF/GLB asset when `meshKind === "model"`.
|
|
672
|
+
* Serialized in snapshots and restored on hydration.
|
|
673
|
+
*/
|
|
674
|
+
modelPath: string;
|
|
675
|
+
/** Editable geometry parameters (width/height/depth, radius, etc.). Ignored when `meshKind === "model"`. */
|
|
671
676
|
meshParameters: MeshGeometryParameters;
|
|
672
677
|
/** Whether all instances cast shadows. */
|
|
673
678
|
castShadow: boolean;
|
|
@@ -676,14 +681,17 @@ declare class InstancedMeshComponent extends Component {
|
|
|
676
681
|
/** Per-instance transforms stored in local space relative to the anchor object. */
|
|
677
682
|
instances: InstanceTransform[];
|
|
678
683
|
/**
|
|
679
|
-
* Live
|
|
684
|
+
* Live runtime container managed by {@link InstancedMeshSystem}:
|
|
685
|
+
* - For primitive kinds: a `THREE.InstancedMesh`.
|
|
686
|
+
* - For `"model"` kind: a `THREE.Group` containing per-mesh `THREE.InstancedMesh` objects.
|
|
680
687
|
* Excluded from snapshot serialization — do **not** read this in hydration code.
|
|
681
688
|
*/
|
|
682
|
-
instancedMesh: THREE.
|
|
689
|
+
instancedMesh: THREE.Object3D | null;
|
|
683
690
|
constructor(meshKind?: InstancedMeshKind, meshParameters?: Partial<MeshGeometryParameters>, options?: {
|
|
684
691
|
castShadow?: boolean;
|
|
685
692
|
receiveShadow?: boolean;
|
|
686
693
|
instances?: InstanceTransform[];
|
|
694
|
+
modelPath?: string;
|
|
687
695
|
});
|
|
688
696
|
/** Sanitize and return a copy of the current mesh parameters with valid values. */
|
|
689
697
|
getSanitizedParameters(): MeshGeometryParameters;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveDracoDecoderPath, applyTransform } from './chunk-
|
|
2
|
-
import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, AudioComponent, VideoComponent } from './chunk-
|
|
1
|
+
import { resolveDracoDecoderPath, applyTransform } from './chunk-FDWNCXU3.js';
|
|
2
|
+
import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, AudioComponent, VideoComponent } from './chunk-R5D5PWXV.js';
|
|
3
3
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
4
4
|
import * as THREE7 from 'three';
|
|
5
5
|
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
@@ -2269,6 +2269,32 @@ var _MeshGeometrySystem = class _MeshGeometrySystem {
|
|
|
2269
2269
|
};
|
|
2270
2270
|
__name(_MeshGeometrySystem, "MeshGeometrySystem");
|
|
2271
2271
|
var MeshGeometrySystem = _MeshGeometrySystem;
|
|
2272
|
+
var DRACO_DECODER_PATH = resolveDracoDecoderPath();
|
|
2273
|
+
var loadGLTF = /* @__PURE__ */ __name((path) => {
|
|
2274
|
+
return new Promise((resolve, reject) => {
|
|
2275
|
+
const loader = new GLTFLoader();
|
|
2276
|
+
try {
|
|
2277
|
+
const dracoLoader = new DRACOLoader();
|
|
2278
|
+
dracoLoader.setDecoderPath(DRACO_DECODER_PATH);
|
|
2279
|
+
loader.setDRACOLoader(dracoLoader);
|
|
2280
|
+
} catch (error) {
|
|
2281
|
+
console.debug("DRACOLoader setup failed or unavailable", error);
|
|
2282
|
+
}
|
|
2283
|
+
loader.load(
|
|
2284
|
+
path,
|
|
2285
|
+
(gltf) => {
|
|
2286
|
+
resolve(gltf);
|
|
2287
|
+
},
|
|
2288
|
+
void 0,
|
|
2289
|
+
(error) => {
|
|
2290
|
+
console.debug("GLTFLoader failed to load", error);
|
|
2291
|
+
reject(error);
|
|
2292
|
+
}
|
|
2293
|
+
);
|
|
2294
|
+
});
|
|
2295
|
+
}, "loadGLTF");
|
|
2296
|
+
|
|
2297
|
+
// core/systems/InstancedMeshSystem.ts
|
|
2272
2298
|
function buildGeometry(component) {
|
|
2273
2299
|
const p = component.getSanitizedParameters();
|
|
2274
2300
|
switch (component.meshKind) {
|
|
@@ -2292,6 +2318,8 @@ function buildGeometry(component) {
|
|
|
2292
2318
|
const params = p;
|
|
2293
2319
|
return new THREE7.CapsuleGeometry(params.radius, params.height, 4, 8);
|
|
2294
2320
|
}
|
|
2321
|
+
default:
|
|
2322
|
+
return new THREE7.BoxGeometry(1, 1, 1);
|
|
2295
2323
|
}
|
|
2296
2324
|
}
|
|
2297
2325
|
__name(buildGeometry, "buildGeometry");
|
|
@@ -2300,6 +2328,7 @@ var _quaternion = new THREE7.Quaternion();
|
|
|
2300
2328
|
var _euler = new THREE7.Euler();
|
|
2301
2329
|
var _scale = new THREE7.Vector3();
|
|
2302
2330
|
var _matrix = new THREE7.Matrix4();
|
|
2331
|
+
var _modelMatrix = new THREE7.Matrix4();
|
|
2303
2332
|
function instanceTransformToMatrix4(inst, out) {
|
|
2304
2333
|
_position.set(inst.position.x, inst.position.y, inst.position.z);
|
|
2305
2334
|
_euler.set(inst.rotation.x, inst.rotation.y, inst.rotation.z, "XYZ");
|
|
@@ -2308,51 +2337,165 @@ function instanceTransformToMatrix4(inst, out) {
|
|
|
2308
2337
|
out.compose(_position, _quaternion, _scale);
|
|
2309
2338
|
}
|
|
2310
2339
|
__name(instanceTransformToMatrix4, "instanceTransformToMatrix4");
|
|
2340
|
+
function disposePrimitiveInstancedMesh(mesh) {
|
|
2341
|
+
mesh.geometry.dispose();
|
|
2342
|
+
if (Array.isArray(mesh.material)) {
|
|
2343
|
+
for (const m of mesh.material) {
|
|
2344
|
+
m.dispose();
|
|
2345
|
+
}
|
|
2346
|
+
} else {
|
|
2347
|
+
mesh.material.dispose();
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
__name(disposePrimitiveInstancedMesh, "disposePrimitiveInstancedMesh");
|
|
2351
|
+
function disposeModelGroup(group) {
|
|
2352
|
+
group.traverse((child) => {
|
|
2353
|
+
const im = child;
|
|
2354
|
+
if (im.isInstancedMesh) {
|
|
2355
|
+
im.geometry.dispose();
|
|
2356
|
+
if (Array.isArray(im.material)) {
|
|
2357
|
+
for (const m of im.material) {
|
|
2358
|
+
m.dispose();
|
|
2359
|
+
}
|
|
2360
|
+
} else {
|
|
2361
|
+
im.material.dispose();
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
__name(disposeModelGroup, "disposeModelGroup");
|
|
2311
2367
|
var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
2312
2368
|
constructor() {
|
|
2313
2369
|
/** Signature tracking for geometry + instance count changes. */
|
|
2314
2370
|
this.geometrySignatures = /* @__PURE__ */ new Map();
|
|
2371
|
+
/** Signature being loaded per entity. Maps entityId → geometrySignature in-flight.
|
|
2372
|
+
* Prevents re-dispatching a load every frame while comp.instancedMesh is still null. */
|
|
2373
|
+
this.loadingSignatures = /* @__PURE__ */ new Map();
|
|
2374
|
+
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
2375
|
+
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
2315
2376
|
}
|
|
2316
2377
|
update(world) {
|
|
2317
2378
|
const entityIds = world.query(InstancedMeshComponent);
|
|
2318
2379
|
const alive = new Set(entityIds);
|
|
2319
2380
|
for (const trackedId of this.geometrySignatures.keys()) {
|
|
2320
|
-
if (!alive.has(trackedId))
|
|
2321
|
-
|
|
2322
|
-
|
|
2381
|
+
if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
|
|
2382
|
+
}
|
|
2383
|
+
for (const trackedId of this.loadingSignatures.keys()) {
|
|
2384
|
+
if (!alive.has(trackedId)) this.loadingSignatures.delete(trackedId);
|
|
2385
|
+
}
|
|
2386
|
+
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
2387
|
+
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
2323
2388
|
}
|
|
2324
2389
|
for (const entityId of entityIds) {
|
|
2325
2390
|
const comp = world.getComponent(
|
|
2326
2391
|
entityId,
|
|
2327
2392
|
InstancedMeshComponent
|
|
2328
2393
|
);
|
|
2329
|
-
if (!comp)
|
|
2330
|
-
continue;
|
|
2331
|
-
}
|
|
2332
|
-
let anchor = null;
|
|
2394
|
+
if (!comp) continue;
|
|
2333
2395
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
}
|
|
2337
|
-
if (!anchor) {
|
|
2338
|
-
continue;
|
|
2339
|
-
}
|
|
2396
|
+
const anchor = objectRef?.object ?? null;
|
|
2397
|
+
if (!anchor) continue;
|
|
2340
2398
|
const instanceCount = comp.instances.length;
|
|
2341
|
-
const geometrySignature = `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
2342
|
-
const
|
|
2399
|
+
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
2400
|
+
const pendingLoadSignature = this.loadingSignatures.get(entityId);
|
|
2401
|
+
const needsRebuild = (comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
|
|
2343
2402
|
if (needsRebuild) {
|
|
2344
2403
|
if (comp.instancedMesh) {
|
|
2345
2404
|
anchor.remove(comp.instancedMesh);
|
|
2346
|
-
comp.instancedMesh.
|
|
2347
|
-
|
|
2348
|
-
for (const m of comp.instancedMesh.material) {
|
|
2349
|
-
m.dispose();
|
|
2350
|
-
}
|
|
2405
|
+
if (comp.instancedMesh.isInstancedMesh) {
|
|
2406
|
+
disposePrimitiveInstancedMesh(comp.instancedMesh);
|
|
2351
2407
|
} else {
|
|
2352
|
-
comp.instancedMesh
|
|
2408
|
+
disposeModelGroup(comp.instancedMesh);
|
|
2353
2409
|
}
|
|
2354
2410
|
comp.instancedMesh = null;
|
|
2355
2411
|
}
|
|
2412
|
+
if (pendingLoadSignature !== void 0 && pendingLoadSignature !== geometrySignature) {
|
|
2413
|
+
this.loadingSignatures.delete(entityId);
|
|
2414
|
+
this.modelMeshEntries.delete(entityId);
|
|
2415
|
+
}
|
|
2416
|
+
if (comp.meshKind === "model") {
|
|
2417
|
+
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
2418
|
+
this.loadingSignatures.set(entityId, geometrySignature);
|
|
2419
|
+
const targetSignature = geometrySignature;
|
|
2420
|
+
const targetEntityId = entityId;
|
|
2421
|
+
loadGLTF(comp.modelPath).then((gltf) => {
|
|
2422
|
+
if (!world.hasEntity(targetEntityId)) {
|
|
2423
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
const currentComp = world.getComponent(
|
|
2427
|
+
targetEntityId,
|
|
2428
|
+
InstancedMeshComponent
|
|
2429
|
+
);
|
|
2430
|
+
if (!currentComp) {
|
|
2431
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
|
|
2435
|
+
if (currentSig !== targetSignature) {
|
|
2436
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
const currentRef = world.getComponent(targetEntityId, Object3DRef);
|
|
2440
|
+
const currentAnchor = currentRef?.object ?? null;
|
|
2441
|
+
if (!currentAnchor) {
|
|
2442
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
if (currentComp.instancedMesh) {
|
|
2446
|
+
currentAnchor.remove(currentComp.instancedMesh);
|
|
2447
|
+
disposeModelGroup(currentComp.instancedMesh);
|
|
2448
|
+
currentComp.instancedMesh = null;
|
|
2449
|
+
}
|
|
2450
|
+
const count2 = Math.max(1, currentComp.instances.length);
|
|
2451
|
+
const entries = [];
|
|
2452
|
+
gltf.scene.updateWorldMatrix(true, true);
|
|
2453
|
+
gltf.scene.traverse((child) => {
|
|
2454
|
+
const meshChild = child;
|
|
2455
|
+
if (!meshChild.isMesh) return;
|
|
2456
|
+
const geometry2 = meshChild.geometry.clone();
|
|
2457
|
+
const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
|
|
2458
|
+
meshChild.updateWorldMatrix(true, false);
|
|
2459
|
+
const localMatrix = meshChild.matrixWorld.clone();
|
|
2460
|
+
const instancedMesh2 = new THREE7.InstancedMesh(
|
|
2461
|
+
geometry2,
|
|
2462
|
+
Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
|
|
2463
|
+
count2
|
|
2464
|
+
);
|
|
2465
|
+
instancedMesh2.castShadow = currentComp.castShadow;
|
|
2466
|
+
instancedMesh2.receiveShadow = currentComp.receiveShadow;
|
|
2467
|
+
for (let i = 0; i < count2; i++) {
|
|
2468
|
+
const inst = currentComp.instances[i] ?? {
|
|
2469
|
+
position: { x: 0, y: 0, z: 0 },
|
|
2470
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
2471
|
+
scale: { x: 1, y: 1, z: 1 }
|
|
2472
|
+
};
|
|
2473
|
+
instanceTransformToMatrix4(inst, _matrix);
|
|
2474
|
+
_modelMatrix.multiplyMatrices(_matrix, localMatrix);
|
|
2475
|
+
instancedMesh2.setMatrixAt(i, _modelMatrix);
|
|
2476
|
+
}
|
|
2477
|
+
instancedMesh2.instanceMatrix.needsUpdate = true;
|
|
2478
|
+
entries.push({ localMatrix, instancedMesh: instancedMesh2 });
|
|
2479
|
+
});
|
|
2480
|
+
if (entries.length === 0) {
|
|
2481
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
const group = new THREE7.Group();
|
|
2485
|
+
for (const entry of entries) {
|
|
2486
|
+
group.add(entry.instancedMesh);
|
|
2487
|
+
}
|
|
2488
|
+
currentAnchor.add(group);
|
|
2489
|
+
currentComp.instancedMesh = group;
|
|
2490
|
+
this.modelMeshEntries.set(targetEntityId, entries);
|
|
2491
|
+
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
2492
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2493
|
+
}).catch(() => {
|
|
2494
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
continue;
|
|
2498
|
+
}
|
|
2356
2499
|
const count = Math.max(1, instanceCount);
|
|
2357
2500
|
const geometry = buildGeometry(comp);
|
|
2358
2501
|
const material = new THREE7.MeshStandardMaterial({ color: "#ffffff" });
|
|
@@ -2373,15 +2516,32 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2373
2516
|
comp.instancedMesh = instancedMesh;
|
|
2374
2517
|
this.geometrySignatures.set(entityId, geometrySignature);
|
|
2375
2518
|
} else {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2519
|
+
if (comp.meshKind === "model") {
|
|
2520
|
+
const entries = this.modelMeshEntries.get(entityId);
|
|
2521
|
+
if (entries) {
|
|
2522
|
+
const count = comp.instances.length;
|
|
2523
|
+
for (const entry of entries) {
|
|
2524
|
+
for (let i = 0; i < count; i++) {
|
|
2525
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
2526
|
+
_modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
|
|
2527
|
+
entry.instancedMesh.setMatrixAt(i, _modelMatrix);
|
|
2528
|
+
}
|
|
2529
|
+
entry.instancedMesh.instanceMatrix.needsUpdate = true;
|
|
2530
|
+
entry.instancedMesh.castShadow = comp.castShadow;
|
|
2531
|
+
entry.instancedMesh.receiveShadow = comp.receiveShadow;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
} else {
|
|
2535
|
+
const im = comp.instancedMesh;
|
|
2536
|
+
const count = comp.instances.length;
|
|
2537
|
+
for (let i = 0; i < count; i++) {
|
|
2538
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
2539
|
+
im.setMatrixAt(i, _matrix);
|
|
2540
|
+
}
|
|
2541
|
+
im.instanceMatrix.needsUpdate = true;
|
|
2542
|
+
im.castShadow = comp.castShadow;
|
|
2543
|
+
im.receiveShadow = comp.receiveShadow;
|
|
2381
2544
|
}
|
|
2382
|
-
im.instanceMatrix.needsUpdate = true;
|
|
2383
|
-
im.castShadow = comp.castShadow;
|
|
2384
|
-
im.receiveShadow = comp.receiveShadow;
|
|
2385
2545
|
}
|
|
2386
2546
|
}
|
|
2387
2547
|
}
|
|
@@ -3419,5 +3579,5 @@ __name(_VideoSystem, "VideoSystem");
|
|
|
3419
3579
|
var VideoSystem = _VideoSystem;
|
|
3420
3580
|
|
|
3421
3581
|
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem };
|
|
3422
|
-
//# sourceMappingURL=chunk-
|
|
3423
|
-
//# sourceMappingURL=chunk-
|
|
3582
|
+
//# sourceMappingURL=chunk-2F6T3BVO.js.map
|
|
3583
|
+
//# sourceMappingURL=chunk-2F6T3BVO.js.map
|