@relu-interactives/spatial-ecs 0.3.1 → 0.3.4
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/{XRRig-Cu-EyliG.d.cts → XRRig-2686IqLQ.d.cts} +5 -5
- package/dist/{XRRig-CAmf04NX.d.ts → XRRig-D2QURXl1.d.ts} +5 -5
- package/dist/{chunk-67WGASUJ.js → chunk-2LVFGVWI.js} +3 -3
- package/dist/{chunk-67WGASUJ.js.map → chunk-2LVFGVWI.js.map} +1 -1
- package/dist/{chunk-PCOZLCXS.js → chunk-4BZYK3JP.js} +14 -6
- package/dist/chunk-4BZYK3JP.js.map +1 -0
- package/dist/{chunk-U3MDYKPV.js → chunk-6QC2PJLD.js} +4 -3
- package/dist/chunk-6QC2PJLD.js.map +1 -0
- package/dist/{chunk-VXUVNC7S.js → chunk-ID266ZUA.js} +199 -5
- package/dist/chunk-ID266ZUA.js.map +1 -0
- package/dist/components/index.cjs +2 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +12 -3
- 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-YYypJaVw.d.cts → index-Bc0YCz1A.d.cts} +27 -1
- package/dist/{index-w1oqWl_M.d.ts → index-BtKOaHfY.d.ts} +1 -1
- package/dist/{index-D84o_UA6.d.ts → index-CRmfSYdj.d.ts} +27 -1
- package/dist/{index-CUFd71ri.d.cts → index-Xu238jLn.d.cts} +1 -1
- package/dist/index.cjs +210 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +198 -1
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +1 -1
- package/dist/systems/index.d.ts +1 -1
- package/dist/systems/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-PCOZLCXS.js.map +0 -1
- package/dist/chunk-U3MDYKPV.js.map +0 -1
- package/dist/chunk-VXUVNC7S.js.map +0 -1
package/dist/systems/index.cjs
CHANGED
|
@@ -18,6 +18,8 @@ var OutputPass_js = require('three/examples/jsm/postprocessing/OutputPass.js');
|
|
|
18
18
|
var HueSaturationShader_js = require('three/examples/jsm/shaders/HueSaturationShader.js');
|
|
19
19
|
var SepiaShader_js = require('three/examples/jsm/shaders/SepiaShader.js');
|
|
20
20
|
var VignetteShader_js = require('three/examples/jsm/shaders/VignetteShader.js');
|
|
21
|
+
var XRControllerModelFactory_js = require('three/examples/jsm/webxr/XRControllerModelFactory.js');
|
|
22
|
+
var XRHandModelFactory_js = require('three/examples/jsm/webxr/XRHandModelFactory.js');
|
|
21
23
|
|
|
22
24
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
23
25
|
function _interopNamespace(e) {
|
|
@@ -2080,7 +2082,8 @@ var _VRTeleportAreaComponent = class _VRTeleportAreaComponent extends Component
|
|
|
2080
2082
|
constructor(options) {
|
|
2081
2083
|
super();
|
|
2082
2084
|
this.enabled = options?.enabled ?? true;
|
|
2083
|
-
|
|
2085
|
+
const shape = options?.shape;
|
|
2086
|
+
this.shape = shape === "cylinder" ? "circle" : options?.shape ?? "plane";
|
|
2084
2087
|
this.width = options?.width ?? 10;
|
|
2085
2088
|
this.depth = options?.depth ?? 10;
|
|
2086
2089
|
}
|
|
@@ -4901,6 +4904,15 @@ function buildComponentValueMaps(snapshot) {
|
|
|
4901
4904
|
snapshot.components,
|
|
4902
4905
|
"ScriptObjectComponent"
|
|
4903
4906
|
),
|
|
4907
|
+
xrRigValues: readByComponent(snapshot.components, "XRRigComponent"),
|
|
4908
|
+
vrTeleportAreaValues: readByComponent(
|
|
4909
|
+
snapshot.components,
|
|
4910
|
+
"VRTeleportAreaComponent"
|
|
4911
|
+
),
|
|
4912
|
+
xrInteractableValues: readByComponent(
|
|
4913
|
+
snapshot.components,
|
|
4914
|
+
"XRInteractableComponent"
|
|
4915
|
+
),
|
|
4904
4916
|
instancedMeshValues: readByComponent(snapshot.components, "InstancedMeshComponent"),
|
|
4905
4917
|
instanceSlotValues: readByComponent(snapshot.components, "InstanceSlotComponent"),
|
|
4906
4918
|
prefabNodeValues: readByComponent(snapshot.components, "PrefabNode"),
|
|
@@ -5026,6 +5038,67 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
|
|
|
5026
5038
|
soc.data = remapEntityRefsInScriptData(data, idMap);
|
|
5027
5039
|
}
|
|
5028
5040
|
}
|
|
5041
|
+
{
|
|
5042
|
+
const sourceXrRig = asRecord3(values.xrRigValues.get(sourceEntityId));
|
|
5043
|
+
const rig = world.getComponent(targetEntityId, XRRigComponent);
|
|
5044
|
+
if (sourceXrRig && rig) {
|
|
5045
|
+
if (typeof sourceXrRig.locomotion === "string") {
|
|
5046
|
+
rig.locomotion = sourceXrRig.locomotion;
|
|
5047
|
+
}
|
|
5048
|
+
if (typeof sourceXrRig.moveSpeed === "number") {
|
|
5049
|
+
rig.moveSpeed = sourceXrRig.moveSpeed;
|
|
5050
|
+
}
|
|
5051
|
+
if (typeof sourceXrRig.snapTurn === "boolean") {
|
|
5052
|
+
rig.snapTurn = sourceXrRig.snapTurn;
|
|
5053
|
+
}
|
|
5054
|
+
if (typeof sourceXrRig.snapTurnDegrees === "number") {
|
|
5055
|
+
rig.snapTurnDegrees = sourceXrRig.snapTurnDegrees;
|
|
5056
|
+
}
|
|
5057
|
+
if (typeof sourceXrRig.fallbackEyeHeight === "number") {
|
|
5058
|
+
rig.fallbackEyeHeight = sourceXrRig.fallbackEyeHeight;
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
{
|
|
5063
|
+
const sourceArea = asRecord3(values.vrTeleportAreaValues.get(sourceEntityId));
|
|
5064
|
+
const area = world.getComponent(targetEntityId, VRTeleportAreaComponent);
|
|
5065
|
+
if (sourceArea && area) {
|
|
5066
|
+
if (typeof sourceArea.enabled === "boolean") {
|
|
5067
|
+
area.enabled = sourceArea.enabled;
|
|
5068
|
+
}
|
|
5069
|
+
if (typeof sourceArea.shape === "string") {
|
|
5070
|
+
area.shape = sourceArea.shape === "cylinder" ? "circle" : sourceArea.shape;
|
|
5071
|
+
}
|
|
5072
|
+
if (typeof sourceArea.width === "number") area.width = sourceArea.width;
|
|
5073
|
+
if (typeof sourceArea.depth === "number") area.depth = sourceArea.depth;
|
|
5074
|
+
}
|
|
5075
|
+
}
|
|
5076
|
+
{
|
|
5077
|
+
const sourceInteractable = asRecord3(
|
|
5078
|
+
values.xrInteractableValues.get(sourceEntityId)
|
|
5079
|
+
);
|
|
5080
|
+
const interactable = world.getComponent(
|
|
5081
|
+
targetEntityId,
|
|
5082
|
+
XRInteractableComponent
|
|
5083
|
+
);
|
|
5084
|
+
if (sourceInteractable && interactable) {
|
|
5085
|
+
if (typeof sourceInteractable.enabled === "boolean") {
|
|
5086
|
+
interactable.enabled = sourceInteractable.enabled;
|
|
5087
|
+
}
|
|
5088
|
+
if (typeof sourceInteractable.grabbable === "boolean") {
|
|
5089
|
+
interactable.grabbable = sourceInteractable.grabbable;
|
|
5090
|
+
}
|
|
5091
|
+
if (typeof sourceInteractable.pointable === "boolean") {
|
|
5092
|
+
interactable.pointable = sourceInteractable.pointable;
|
|
5093
|
+
}
|
|
5094
|
+
if (typeof sourceInteractable.grabMode === "string") {
|
|
5095
|
+
interactable.grabMode = sourceInteractable.grabMode;
|
|
5096
|
+
}
|
|
5097
|
+
if (typeof sourceInteractable.highlightOnHover === "boolean") {
|
|
5098
|
+
interactable.highlightOnHover = sourceInteractable.highlightOnHover;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5029
5102
|
{
|
|
5030
5103
|
const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
|
|
5031
5104
|
if (imComponent && imComponent.instanceEntityIds.length > 0) {
|
|
@@ -8043,6 +8116,128 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
8043
8116
|
};
|
|
8044
8117
|
__name(_XRSessionSystem, "XRSessionSystem");
|
|
8045
8118
|
var XRSessionSystem = _XRSessionSystem;
|
|
8119
|
+
function buildGeometry2(area) {
|
|
8120
|
+
if (area.shape === "circle") {
|
|
8121
|
+
const radius = Math.max(5e-3, area.width / 2);
|
|
8122
|
+
return new THREE14__namespace.CircleGeometry(radius, 48);
|
|
8123
|
+
}
|
|
8124
|
+
return new THREE14__namespace.PlaneGeometry(
|
|
8125
|
+
Math.max(0.01, area.width),
|
|
8126
|
+
Math.max(0.01, area.depth)
|
|
8127
|
+
);
|
|
8128
|
+
}
|
|
8129
|
+
__name(buildGeometry2, "buildGeometry");
|
|
8130
|
+
function signatureOf(area) {
|
|
8131
|
+
return `${area.shape}:${area.width}:${area.depth}`;
|
|
8132
|
+
}
|
|
8133
|
+
__name(signatureOf, "signatureOf");
|
|
8134
|
+
var _VRTeleportAreaSystem = class _VRTeleportAreaSystem {
|
|
8135
|
+
constructor() {
|
|
8136
|
+
this.signatures = /* @__PURE__ */ new Map();
|
|
8137
|
+
}
|
|
8138
|
+
update(world) {
|
|
8139
|
+
const entityIds = world.query(VRTeleportAreaComponent, Object3DRef);
|
|
8140
|
+
const alive = new Set(entityIds);
|
|
8141
|
+
for (const tracked of this.signatures.keys()) {
|
|
8142
|
+
if (!alive.has(tracked)) this.signatures.delete(tracked);
|
|
8143
|
+
}
|
|
8144
|
+
for (const entityId of entityIds) {
|
|
8145
|
+
const area = world.getComponent(entityId, VRTeleportAreaComponent);
|
|
8146
|
+
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
8147
|
+
if (!area || !(object instanceof THREE14__namespace.Mesh)) continue;
|
|
8148
|
+
const signature = signatureOf(area);
|
|
8149
|
+
if (this.signatures.get(entityId) === signature) continue;
|
|
8150
|
+
this.signatures.set(entityId, signature);
|
|
8151
|
+
object.geometry?.dispose?.();
|
|
8152
|
+
object.geometry = buildGeometry2(area);
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
};
|
|
8156
|
+
__name(_VRTeleportAreaSystem, "VRTeleportAreaSystem");
|
|
8157
|
+
var VRTeleportAreaSystem = _VRTeleportAreaSystem;
|
|
8158
|
+
var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
8159
|
+
constructor(slots = 2) {
|
|
8160
|
+
this.controllerModelFactory = new XRControllerModelFactory_js.XRControllerModelFactory();
|
|
8161
|
+
this.handModelFactory = new XRHandModelFactory_js.XRHandModelFactory();
|
|
8162
|
+
this.group = new THREE14__namespace.Group();
|
|
8163
|
+
this.built = false;
|
|
8164
|
+
this.attachedTo = null;
|
|
8165
|
+
/** Index → whether we've already attached visuals for that slot. */
|
|
8166
|
+
this.ready = /* @__PURE__ */ new Set();
|
|
8167
|
+
this.slots = slots;
|
|
8168
|
+
this.group.name = "XRControllerVisuals";
|
|
8169
|
+
this.group.userData.ecsPreviewHidden = true;
|
|
8170
|
+
}
|
|
8171
|
+
update(world) {
|
|
8172
|
+
const renderer = world.getRenderer();
|
|
8173
|
+
if (!renderer.xr?.enabled) return;
|
|
8174
|
+
this.ensureAttached(world);
|
|
8175
|
+
if (this.built) return;
|
|
8176
|
+
for (let index = 0; index < this.slots; index += 1) {
|
|
8177
|
+
if (this.ready.has(index)) continue;
|
|
8178
|
+
const controller = renderer.xr.getController(index);
|
|
8179
|
+
const grip = renderer.xr.getControllerGrip(index);
|
|
8180
|
+
const hand = renderer.xr.getHand(index);
|
|
8181
|
+
if (!controller || !grip || !hand) continue;
|
|
8182
|
+
controller.add(this.createRay());
|
|
8183
|
+
this.group.add(controller);
|
|
8184
|
+
grip.add(this.controllerModelFactory.createControllerModel(grip));
|
|
8185
|
+
this.group.add(grip);
|
|
8186
|
+
hand.add(this.handModelFactory.createHandModel(hand, "mesh"));
|
|
8187
|
+
this.group.add(hand);
|
|
8188
|
+
this.ready.add(index);
|
|
8189
|
+
}
|
|
8190
|
+
if (this.ready.size >= this.slots) {
|
|
8191
|
+
this.built = true;
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
/**
|
|
8195
|
+
* Parent the visuals to the XR rig when there is one, so locomotion moves the
|
|
8196
|
+
* hands with the player. Falls back to the scene root.
|
|
8197
|
+
*/
|
|
8198
|
+
ensureAttached(world) {
|
|
8199
|
+
const camera = world.getCamera();
|
|
8200
|
+
const target = camera.parent ?? world.getScene();
|
|
8201
|
+
if (this.attachedTo === target) return;
|
|
8202
|
+
target.add(this.group);
|
|
8203
|
+
this.attachedTo = target;
|
|
8204
|
+
}
|
|
8205
|
+
createRay() {
|
|
8206
|
+
const geometry = new THREE14__namespace.BufferGeometry().setFromPoints([
|
|
8207
|
+
new THREE14__namespace.Vector3(0, 0, 0),
|
|
8208
|
+
new THREE14__namespace.Vector3(0, 0, -5)
|
|
8209
|
+
]);
|
|
8210
|
+
const material = new THREE14__namespace.LineBasicMaterial({
|
|
8211
|
+
color: "#4da3ff",
|
|
8212
|
+
transparent: true,
|
|
8213
|
+
opacity: 0.6,
|
|
8214
|
+
depthTest: false
|
|
8215
|
+
});
|
|
8216
|
+
const line = new THREE14__namespace.Line(geometry, material);
|
|
8217
|
+
line.name = "XRPointerRay";
|
|
8218
|
+
line.renderOrder = 999;
|
|
8219
|
+
return line;
|
|
8220
|
+
}
|
|
8221
|
+
dispose() {
|
|
8222
|
+
this.group.removeFromParent();
|
|
8223
|
+
this.group.traverse((child) => {
|
|
8224
|
+
const mesh = child;
|
|
8225
|
+
mesh.geometry?.dispose?.();
|
|
8226
|
+
const material = mesh.material;
|
|
8227
|
+
if (Array.isArray(material)) {
|
|
8228
|
+
for (const entry of material) entry.dispose?.();
|
|
8229
|
+
} else {
|
|
8230
|
+
material?.dispose?.();
|
|
8231
|
+
}
|
|
8232
|
+
});
|
|
8233
|
+
this.group.clear();
|
|
8234
|
+
this.ready.clear();
|
|
8235
|
+
this.built = false;
|
|
8236
|
+
this.attachedTo = null;
|
|
8237
|
+
}
|
|
8238
|
+
};
|
|
8239
|
+
__name(_XRControllerVisualSystem, "XRControllerVisualSystem");
|
|
8240
|
+
var XRControllerVisualSystem = _XRControllerVisualSystem;
|
|
8046
8241
|
|
|
8047
8242
|
exports.AnimationSystem = AnimationSystem;
|
|
8048
8243
|
exports.AudioSystem = AudioSystem;
|
|
@@ -8063,7 +8258,9 @@ exports.SCRIPT_OBJECT_ROOT_FLAG = SCRIPT_OBJECT_ROOT_FLAG;
|
|
|
8063
8258
|
exports.ScriptBehaviourSystem = ScriptBehaviourSystem;
|
|
8064
8259
|
exports.ScriptObjectSystem = ScriptObjectSystem;
|
|
8065
8260
|
exports.TransformSyncSystem = TransformSyncSystem;
|
|
8261
|
+
exports.VRTeleportAreaSystem = VRTeleportAreaSystem;
|
|
8066
8262
|
exports.VideoSystem = VideoSystem;
|
|
8263
|
+
exports.XRControllerVisualSystem = XRControllerVisualSystem;
|
|
8067
8264
|
exports.XRInputSystem = XRInputSystem;
|
|
8068
8265
|
exports.XRInteractionSystem = XRInteractionSystem;
|
|
8069
8266
|
exports.XRLocomotionSystem = XRLocomotionSystem;
|