@needle-tools/engine 4.1.0-experimental.12 → 4.1.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/CHANGELOG.md +72 -10
- package/README.md +28 -17
- package/components.needle.json +1 -1
- package/dist/gltf-progressive.js +220 -221
- package/dist/gltf-progressive.light.js +220 -221
- package/dist/gltf-progressive.light.min.js +6 -6
- package/dist/gltf-progressive.light.umd.cjs +7 -7
- package/dist/gltf-progressive.min.js +6 -6
- package/dist/gltf-progressive.umd.cjs +7 -7
- package/dist/needle-engine.bundle.js +8286 -7952
- package/dist/needle-engine.bundle.light.js +8239 -7905
- package/dist/needle-engine.bundle.light.min.js +270 -227
- package/dist/needle-engine.bundle.light.umd.cjs +181 -138
- package/dist/needle-engine.bundle.min.js +270 -227
- package/dist/needle-engine.bundle.umd.cjs +177 -134
- package/dist/needle-engine.d.ts +140 -0
- package/dist/needle-engine.js +597 -590
- package/dist/needle-engine.light.d.ts +140 -0
- package/dist/needle-engine.light.js +597 -590
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/postprocessing.js +1 -1
- package/dist/postprocessing.light.js +1 -1
- package/dist/postprocessing.light.min.js +1 -1
- package/dist/postprocessing.min.js +1 -1
- package/dist/three-examples.js +2809 -2450
- package/dist/three-examples.light.js +2809 -2450
- package/dist/three-examples.light.min.js +47 -15
- package/dist/three-examples.light.umd.cjs +47 -15
- package/dist/three-examples.min.js +47 -15
- package/dist/three-examples.umd.cjs +47 -15
- package/dist/three-mesh-ui.js +1 -1
- package/dist/three-mesh-ui.light.js +1 -1
- package/dist/three-mesh-ui.light.min.js +1 -1
- package/dist/three-mesh-ui.min.js +1 -1
- package/dist/three.js +577 -572
- package/dist/three.light.js +577 -572
- package/dist/three.light.min.js +170 -170
- package/dist/three.light.umd.cjs +170 -170
- package/dist/three.min.js +170 -170
- package/dist/three.umd.cjs +170 -170
- package/dist/vendor.js +1327 -1331
- package/dist/vendor.light.js +1327 -1331
- package/dist/vendor.light.min.js +33 -33
- package/dist/vendor.light.umd.cjs +33 -33
- package/dist/vendor.min.js +33 -33
- package/dist/vendor.umd.cjs +33 -33
- package/lib/engine/assets/index.js.map +1 -1
- package/lib/engine/engine.d.ts +4 -0
- package/lib/engine/engine.js +12 -0
- package/lib/engine/engine.js.map +1 -0
- package/lib/engine/engine_addressables.d.ts +6 -4
- package/lib/engine/engine_addressables.js +8 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_context.d.ts +3 -2
- package/lib/engine/engine_context.js +28 -4
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +2 -12
- package/lib/engine/engine_gameobject.js +5 -15
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +5 -0
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_input.d.ts +19 -6
- package/lib/engine/engine_input.js +0 -10
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_license.js +1 -1
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_modules.d.ts +7 -0
- package/lib/engine/engine_modules.js +7 -0
- package/lib/engine/engine_modules.js.map +1 -1
- package/lib/engine/engine_networking_auto.js +6 -11
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.d.ts +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +6 -4
- package/lib/engine/engine_physics_rapier.js +38 -24
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_scenetools.js +6 -2
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_types.d.ts +9 -2
- package/lib/engine/engine_types.js +6 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_web_api.d.ts +12 -0
- package/lib/engine/engine_web_api.js +113 -0
- package/lib/engine/engine_web_api.js.map +1 -0
- package/lib/engine/export/gltf/Writers.js.map +1 -1
- package/lib/engine/export/gltf/index.js +11 -1
- package/lib/engine/export/gltf/index.js.map +1 -1
- package/lib/engine/export/utils.d.ts +2 -0
- package/lib/engine/export/utils.js +8 -0
- package/lib/engine/export/utils.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_gameobject_data.js +1 -1
- package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -1
- package/lib/engine/js-extensions/Object3D.d.ts +5 -1
- package/lib/engine/js-extensions/Object3D.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +8 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +3 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +7 -4
- package/lib/engine-components/Camera.js +13 -10
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Collider.js +4 -5
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +4 -3
- package/lib/engine-components/Component.js +6 -7
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +1 -1
- package/lib/engine-components/ContactShadows.js +7 -0
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/FlyControls.d.ts +10 -0
- package/lib/engine-components/FlyControls.js +29 -0
- package/lib/engine-components/FlyControls.js.map +1 -0
- package/lib/engine-components/GroundProjection.d.ts +1 -1
- package/lib/engine-components/GroundProjection.js +39 -32
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +9 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +1 -0
- package/lib/engine-components/RigidBody.js +11 -4
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +1 -1
- package/lib/engine-components/SceneSwitcher.js +1 -1
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.d.ts +2 -2
- package/lib/engine-components/SpatialTrigger.js +4 -4
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +7 -1
- package/lib/engine-components/TransformGizmo.js +39 -32
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js +0 -1
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js +23 -4
- package/lib/engine-components/export/gltf/GltfExport.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +2 -2
- package/lib/engine-components/export/usdz/index.d.ts +1 -1
- package/lib/engine-components/export/usdz/index.js +1 -1
- package/lib/engine-components/export/usdz/index.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +5 -6
- package/lib/engine-components/particlesystem/ParticleSystem.js +23 -9
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystemModules.js +8 -2
- package/lib/engine-components/particlesystem/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Pixelation.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +2 -0
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +29 -20
- package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Vignette.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/webxr/Avatar.js +3 -3
- package/lib/engine-components/webxr/Avatar.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.js +22 -13
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +4 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js +14 -4
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/engine-components/webxr/WebXRRig.d.ts +11 -1
- package/lib/engine-components/webxr/WebXRRig.js +13 -1
- package/lib/engine-components/webxr/WebXRRig.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +4 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js +18 -30
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/needle-engine.js +5 -5
- package/lib/needle-engine.js.map +1 -1
- package/package.json +14 -8
- package/plugins/common/config.cjs +22 -6
- package/plugins/common/config.js +27 -11
- package/plugins/next/next.js +47 -4
- package/plugins/vite/transform.js +3 -3
- package/src/engine/assets/index.ts +1 -0
- package/src/engine/codegen/register_types.ts +2 -2
- package/src/engine/engine_addressables.ts +19 -12
- package/src/engine/engine_context.ts +33 -8
- package/src/engine/engine_gameobject.ts +12 -16
- package/src/engine/engine_gltf_builtin_components.ts +7 -1
- package/src/engine/engine_input.ts +12 -5
- package/src/engine/engine_license.ts +2 -1
- package/src/engine/engine_modules.ts +7 -0
- package/src/engine/engine_networking_auto.ts +7 -22
- package/src/engine/engine_networking_instantiate.ts +1 -1
- package/src/engine/engine_physics_rapier.ts +48 -26
- package/src/engine/engine_scenetools.ts +6 -2
- package/src/engine/engine_types.ts +10 -2
- package/src/engine/export/gltf/Writers.ts +0 -1
- package/src/engine/export/gltf/index.ts +13 -3
- package/src/engine/export/index.ts +1 -1
- package/src/engine/export/utils.ts +10 -0
- package/src/engine/extensions/NEEDLE_gameobject_data.ts +1 -2
- package/src/engine/js-extensions/Object3D.ts +6 -1
- package/src/engine/webcomponents/needle menu/needle-menu.ts +16 -10
- package/src/engine/xr/NeedleXRSession.ts +4 -1
- package/src/engine-components/AvatarLoader.ts +1 -1
- package/src/engine-components/Camera.ts +14 -11
- package/src/engine-components/Collider.ts +4 -4
- package/src/engine-components/Component.ts +13 -7
- package/src/engine-components/ContactShadows.ts +11 -2
- package/src/engine-components/GroundProjection.ts +46 -38
- package/src/engine-components/OrbitControls.ts +9 -1
- package/src/engine-components/RigidBody.ts +13 -5
- package/src/engine-components/SceneSwitcher.ts +1 -1
- package/src/engine-components/SpatialTrigger.ts +6 -6
- package/src/engine-components/TransformGizmo.ts +41 -33
- package/src/engine-components/VideoPlayer.ts +0 -1
- package/src/engine-components/export/gltf/GltfExport.ts +26 -6
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2 -2
- package/src/engine-components/export/usdz/index.ts +1 -1
- package/src/engine-components/particlesystem/ParticleSystem.ts +26 -10
- package/src/engine-components/particlesystem/ParticleSystemModules.ts +10 -3
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +0 -1
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +32 -21
- package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +0 -1
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +2 -3
- package/src/engine-components/webxr/Avatar.ts +3 -3
- package/src/engine-components/webxr/WebXR.ts +23 -14
- package/src/engine-components/webxr/WebXRImageTracking.ts +23 -8
- package/src/engine-components/webxr/WebXRRig.ts +15 -2
- package/src/engine-components-experimental/networking/PlayerSync.ts +18 -37
- package/src/needle-engine.ts +5 -5
|
@@ -9,7 +9,7 @@ import { Gizmos } from "../engine/engine_gizmos.js";
|
|
|
9
9
|
import { onStart } from "../engine/engine_lifecycle_api.js";
|
|
10
10
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
11
11
|
import { getBoundingBox, getVisibleInCustomShadowRendering } from "../engine/engine_three_utils.js";
|
|
12
|
-
import { IGameObject, Vec3 } from "../engine/engine_types.js";
|
|
12
|
+
import { HideFlags, IGameObject, Vec3 } from "../engine/engine_types.js";
|
|
13
13
|
import { getParam } from "../engine/engine_utils.js"
|
|
14
14
|
import { setCustomVisibility } from "../engine/js-extensions/Layers.js";
|
|
15
15
|
import { Behaviour, GameObject } from "./Component.js";
|
|
@@ -37,7 +37,7 @@ onStart(ctx => {
|
|
|
37
37
|
*/
|
|
38
38
|
export class ContactShadows extends Behaviour {
|
|
39
39
|
|
|
40
|
-
private static _instances: Map<Context, ContactShadows> = new Map();
|
|
40
|
+
private static readonly _instances: Map<Context, ContactShadows> = new Map();
|
|
41
41
|
/**
|
|
42
42
|
* Create contact shadows for the scene. Automatically fits the shadows to the scene.
|
|
43
43
|
* The instance of contact shadows will be created only once.
|
|
@@ -162,10 +162,14 @@ export class ContactShadows extends Behaviour {
|
|
|
162
162
|
|
|
163
163
|
/** @internal */
|
|
164
164
|
awake() {
|
|
165
|
+
ContactShadows._instances.set(this.context, this);
|
|
166
|
+
this.shadowsRoot.hideFlags = HideFlags.DontExport;
|
|
167
|
+
|
|
165
168
|
// ignore self for autofitting
|
|
166
169
|
setAutoFitEnabled(this.shadowsRoot, false);
|
|
167
170
|
}
|
|
168
171
|
|
|
172
|
+
|
|
169
173
|
/** @internal */
|
|
170
174
|
start(): void {
|
|
171
175
|
if (debug) console.log("Create ContactShadows on " + this.gameObject.name, this)
|
|
@@ -280,6 +284,11 @@ export class ContactShadows extends Behaviour {
|
|
|
280
284
|
|
|
281
285
|
/** @internal */
|
|
282
286
|
onDestroy(): void {
|
|
287
|
+
const instance = ContactShadows._instances.get(this.context);
|
|
288
|
+
if (instance === this) {
|
|
289
|
+
ContactShadows._instances.delete(this.context);
|
|
290
|
+
}
|
|
291
|
+
|
|
283
292
|
// dispose the render targets
|
|
284
293
|
this.renderTarget?.dispose();
|
|
285
294
|
this.renderTargetBlur?.dispose();
|
|
@@ -3,7 +3,7 @@ import { GroundedSkybox as GroundProjection } from 'three/examples/jsm/objects/G
|
|
|
3
3
|
|
|
4
4
|
import { Gizmos } from "../engine/engine_gizmos.js";
|
|
5
5
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
6
|
-
import { getBoundingBox, getTempVector, getWorldScale, Graphics, setVisibleInCustomShadowRendering,setWorldPosition } from "../engine/engine_three_utils.js";
|
|
6
|
+
import { getBoundingBox, getTempVector, getWorldScale, Graphics, setVisibleInCustomShadowRendering, setWorldPosition } from "../engine/engine_three_utils.js";
|
|
7
7
|
import { delayForFrames, getParam, Watch as Watch } from "../engine/engine_utils.js";
|
|
8
8
|
import { Behaviour } from "./Component.js";
|
|
9
9
|
|
|
@@ -37,7 +37,7 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
37
37
|
@serializable()
|
|
38
38
|
set radius(val: number) {
|
|
39
39
|
this._radius = val;
|
|
40
|
-
this.updateProjection();
|
|
40
|
+
if (this._projection) this.updateProjection();
|
|
41
41
|
}
|
|
42
42
|
get radius(): number { return this._radius; }
|
|
43
43
|
private _radius: number = 50;
|
|
@@ -49,7 +49,7 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
49
49
|
@serializable()
|
|
50
50
|
set height(val: number) {
|
|
51
51
|
this._height = val;
|
|
52
|
-
this.updateProjection();
|
|
52
|
+
if (this._projection) this.updateProjection();
|
|
53
53
|
}
|
|
54
54
|
get height(): number { return this._height; }
|
|
55
55
|
private _height: number = 3;
|
|
@@ -68,7 +68,7 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
68
68
|
get arBlending(): number { return this._arblending; }
|
|
69
69
|
private _arblending = 0;
|
|
70
70
|
|
|
71
|
-
private
|
|
71
|
+
private _lastBackground?: Texture;
|
|
72
72
|
private _lastRadius?: number;
|
|
73
73
|
private _lastHeight?: number;
|
|
74
74
|
private _projection?: GroundProjection;
|
|
@@ -88,9 +88,10 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
88
88
|
this.updateAndCreate();
|
|
89
89
|
}
|
|
90
90
|
if (!this._watcher) {
|
|
91
|
-
this._watcher = new Watch(this.context.scene, "
|
|
91
|
+
this._watcher = new Watch(this.context.scene, "background");
|
|
92
92
|
this._watcher.subscribeWrite(_ => {
|
|
93
|
-
this.
|
|
93
|
+
if (debug) console.log("Background changed", this.context.scene.background);
|
|
94
|
+
this._needsTextureUpdate = true;
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
}
|
|
@@ -101,13 +102,13 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
101
102
|
}
|
|
102
103
|
/** @internal */
|
|
103
104
|
onEnterXR(): void {
|
|
104
|
-
if(!this.activeAndEnabled) return;
|
|
105
|
+
if (!this.activeAndEnabled) return;
|
|
105
106
|
this._needsTextureUpdate = true;
|
|
106
107
|
this.updateProjection();
|
|
107
108
|
}
|
|
108
109
|
/** @internal */
|
|
109
110
|
async onLeaveXR() {
|
|
110
|
-
if(!this.activeAndEnabled) return;
|
|
111
|
+
if (!this.activeAndEnabled) return;
|
|
111
112
|
await delayForFrames(1);
|
|
112
113
|
this.updateProjection();
|
|
113
114
|
}
|
|
@@ -121,8 +122,8 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
121
122
|
if (blurrinessChanged) {
|
|
122
123
|
this.updateProjection();
|
|
123
124
|
}
|
|
124
|
-
else if (this._needsTextureUpdate) {
|
|
125
|
-
this.updateBlurriness();
|
|
125
|
+
else if (this._needsTextureUpdate && this.context.scene.background instanceof Texture) {
|
|
126
|
+
this.updateBlurriness(this.context.scene.background, this.context.scene.backgroundBlurriness);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -138,10 +139,16 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
138
139
|
* Updates the ground projection. This is called automatically when the environment or settings change.
|
|
139
140
|
*/
|
|
140
141
|
updateProjection() {
|
|
141
|
-
if (!this.context.scene.
|
|
142
|
+
if (!this.context.scene.background) {
|
|
143
|
+
this._projection?.removeFromParent();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const backgroundTexture = this.context.scene.background;
|
|
147
|
+
if (!(backgroundTexture instanceof Texture)) {
|
|
142
148
|
this._projection?.removeFromParent();
|
|
143
149
|
return;
|
|
144
150
|
}
|
|
151
|
+
|
|
145
152
|
if (this.context.xr?.isPassThrough || this.context.xr?.isAR) {
|
|
146
153
|
if (this.arBlending === 0) {
|
|
147
154
|
this._projection?.removeFromParent();
|
|
@@ -152,25 +159,25 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
152
159
|
if (!this.gameObject || this.destroyed) {
|
|
153
160
|
return;
|
|
154
161
|
}
|
|
155
|
-
|
|
162
|
+
|
|
156
163
|
let needsNewAutoFit = true;
|
|
157
164
|
// offset here must be zero (and not .01) because the plane occlusion (when mesh tracking is active) is otherwise not correct
|
|
158
165
|
const offset = 0;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
|
|
167
|
+
const hasChanged = backgroundTexture !== this._lastBackground || this._height !== this._lastHeight || this._radius !== this._lastRadius;
|
|
168
|
+
|
|
169
|
+
if (!this._projection || hasChanged) {
|
|
170
|
+
if (debug) console.log("Create/Update Ground Projection", backgroundTexture.name);
|
|
171
|
+
|
|
162
172
|
this._projection?.removeFromParent();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
this._projection = new GroundProjection(backgroundTexture, this._height, this._radius, 64);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
console.error("Error creating three GroundProjection", e);
|
|
179
|
+
return;
|
|
171
180
|
}
|
|
172
|
-
else
|
|
173
|
-
needsNewAutoFit = false;
|
|
174
181
|
this._projection.position.y = this._height - offset;
|
|
175
182
|
this._projection.name = "GroundProjection";
|
|
176
183
|
setVisibleInCustomShadowRendering(this._projection, false);
|
|
@@ -205,35 +212,35 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
205
212
|
this.env.radius = this._radius;
|
|
206
213
|
this.env.height = this._height;
|
|
207
214
|
*/
|
|
208
|
-
|
|
215
|
+
|
|
209
216
|
if (this.context.scene.backgroundBlurriness > 0.001 && this._needsTextureUpdate) {
|
|
210
|
-
this.updateBlurriness();
|
|
217
|
+
this.updateBlurriness(backgroundTexture, this.context.scene.backgroundBlurriness);
|
|
211
218
|
}
|
|
212
219
|
|
|
213
|
-
this.
|
|
220
|
+
this._lastBackground = backgroundTexture;
|
|
214
221
|
this._lastHeight = this._height;
|
|
215
222
|
this._lastRadius = this._radius;
|
|
216
|
-
|
|
217
223
|
this._needsTextureUpdate = false;
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
private _blurrynessShader: ShaderMaterial | null = null;
|
|
221
227
|
private _lastBlurriness: number = -1;
|
|
222
228
|
|
|
223
|
-
private updateBlurriness() {
|
|
229
|
+
private updateBlurriness(texture: Texture, blurriness: number) {
|
|
224
230
|
if (!this._projection) {
|
|
225
231
|
return;
|
|
226
232
|
}
|
|
227
|
-
else if (!
|
|
233
|
+
else if (!texture) {
|
|
228
234
|
return;
|
|
229
235
|
}
|
|
236
|
+
|
|
230
237
|
this._needsTextureUpdate = false;
|
|
231
|
-
if (debug) console.log("Update Blurriness",
|
|
238
|
+
if (debug) console.log("Update Blurriness", blurriness);
|
|
232
239
|
this._blurrynessShader ??= new ShaderMaterial({
|
|
233
240
|
name: "GroundProjectionBlurriness",
|
|
234
241
|
uniforms: {
|
|
235
|
-
map: { value:
|
|
236
|
-
blurriness: { value:
|
|
242
|
+
map: { value: texture },
|
|
243
|
+
blurriness: { value: blurriness },
|
|
237
244
|
blending: { value: 0 },
|
|
238
245
|
alphaFactor: { value: 1 }
|
|
239
246
|
},
|
|
@@ -241,9 +248,10 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
241
248
|
fragmentShader: blurFragmentShader
|
|
242
249
|
});
|
|
243
250
|
this._blurrynessShader.depthWrite = false;
|
|
244
|
-
this._blurrynessShader.uniforms.
|
|
245
|
-
this.
|
|
246
|
-
this.
|
|
251
|
+
this._blurrynessShader.uniforms.map.value = texture;
|
|
252
|
+
this._blurrynessShader.uniforms.blurriness.value = 1;//blurriness;
|
|
253
|
+
this._lastBlurriness = blurriness;
|
|
254
|
+
texture.needsUpdate = true;
|
|
247
255
|
|
|
248
256
|
const wasTransparent = this._projection.material.transparent;
|
|
249
257
|
this._projection.material.transparent = (this.context.xr?.isAR === true && this.arBlending > 0.000001) ?? false;
|
|
@@ -266,7 +274,7 @@ export class GroundProjectedEnv extends Behaviour {
|
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
// Update the texture
|
|
269
|
-
this._projection.material.map = Graphics.copyTexture(
|
|
277
|
+
this._projection.material.map = Graphics.copyTexture(texture, this._blurrynessShader);
|
|
270
278
|
this._projection.material.depthTest = true;
|
|
271
279
|
this._projection.material.depthWrite = false;
|
|
272
280
|
}
|
|
@@ -287,7 +287,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
287
287
|
cam = this.gameObject;
|
|
288
288
|
}
|
|
289
289
|
if (cam) setCameraController(cam, this, true);
|
|
290
|
-
if (!this._controls && cam instanceof
|
|
290
|
+
if (!this._controls && cam instanceof Object3D) {
|
|
291
291
|
this._cameraObject = cam;
|
|
292
292
|
// Using the parent if possible to make it possible to disable input on the canvas
|
|
293
293
|
// for having HTML content behind it and still receive input
|
|
@@ -297,6 +297,14 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
297
297
|
this._controls = new ThreeOrbitControls(cam!, element);
|
|
298
298
|
cam?.quaternion.copy(mat!)
|
|
299
299
|
if (defaultKeys === undefined) defaultKeys = { ...this._controls.keys };
|
|
300
|
+
// set controls look point in front of the current camera by default
|
|
301
|
+
// it may be overriden by the autoTarget feature
|
|
302
|
+
// but if we don't do this and autoTarget is OFF then the camera will turn to look at 0 0 0 of the scene
|
|
303
|
+
const worldPosition = getWorldPosition(cam);
|
|
304
|
+
const forward = this.gameObject.worldForward;
|
|
305
|
+
const dist = 2.5;
|
|
306
|
+
const lookAt = worldPosition.clone().sub(forward.multiplyScalar(dist));
|
|
307
|
+
this._controls.target.copy(lookAt);
|
|
300
308
|
}
|
|
301
309
|
|
|
302
310
|
if (this._controls) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Matrix4, Object3D, Quaternion, Vector3, Vector3Like } from "three";
|
|
2
2
|
|
|
3
3
|
import { isDevEnvironment } from "../engine/debug/index.js";
|
|
4
|
+
import { MODULES } from "../engine/engine_modules.js";
|
|
4
5
|
import { CollisionDetectionMode, RigidbodyConstraints } from "../engine/engine_physics.types.js";
|
|
5
6
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
6
7
|
import { Context, FrameEvent } from "../engine/engine_setup.js";
|
|
7
8
|
import { getWorldPosition } from "../engine/engine_three_utils.js";
|
|
8
9
|
import type { IRigidbody, Vec3 } from "../engine/engine_types.js";
|
|
9
10
|
import { validate } from "../engine/engine_util_decorator.js";
|
|
10
|
-
import { Watch } from "../engine/engine_utils.js";
|
|
11
|
+
import { delayForFrames, Watch } from "../engine/engine_utils.js";
|
|
11
12
|
import { Behaviour } from "./Component.js";
|
|
12
13
|
|
|
13
14
|
class TransformWatch {
|
|
@@ -139,6 +140,8 @@ class TransformWatch {
|
|
|
139
140
|
*/
|
|
140
141
|
export class Rigidbody extends Behaviour implements IRigidbody {
|
|
141
142
|
|
|
143
|
+
get isRigidbody() { return true; }
|
|
144
|
+
|
|
142
145
|
/** When true the mass will be automatically calculated by the attached colliders */
|
|
143
146
|
@validate()
|
|
144
147
|
autoMass: boolean = true;
|
|
@@ -316,11 +319,16 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
316
319
|
}
|
|
317
320
|
this._watch.start(true, true);
|
|
318
321
|
this.startCoroutine(this.beforePhysics(), FrameEvent.LateUpdate);
|
|
319
|
-
if (isDevEnvironment()
|
|
322
|
+
if (isDevEnvironment()) {
|
|
320
323
|
if (!globalThis["NEEDLE_USE_RAPIER"])
|
|
321
324
|
console.warn(`Rigidbody could not be created: Rapier physics are explicitly disabled.`);
|
|
322
|
-
else
|
|
323
|
-
|
|
325
|
+
else {
|
|
326
|
+
MODULES.RAPIER_PHYSICS.ready().then(async () => {
|
|
327
|
+
await delayForFrames(3);
|
|
328
|
+
if (!this.context.physics.engine?.getBody(this))
|
|
329
|
+
console.warn(`Rigidbody could not be created. Ensure \"${this.name}\" has a Collider component.`);
|
|
330
|
+
})
|
|
331
|
+
}
|
|
324
332
|
}
|
|
325
333
|
}
|
|
326
334
|
|
|
@@ -338,7 +346,7 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
338
346
|
}
|
|
339
347
|
|
|
340
348
|
// need to do this right before updating physics to prevent rendered object glitching through physical bodies
|
|
341
|
-
*beforePhysics() {
|
|
349
|
+
* beforePhysics() {
|
|
342
350
|
while (true) {
|
|
343
351
|
if (this._propertiesChanged) {
|
|
344
352
|
this._propertiesChanged = false;
|
|
@@ -760,7 +760,7 @@ export class SceneSwitcher extends Behaviour {
|
|
|
760
760
|
}
|
|
761
761
|
this._lastLoadingScene = this.loadingScene;
|
|
762
762
|
if (!this._loadingScenePromise) {
|
|
763
|
-
this._loadingScenePromise = this.loadingScene?.loadAssetAsync();
|
|
763
|
+
this._loadingScenePromise = this.loadingScene?.loadAssetAsync().then(res => res != null);
|
|
764
764
|
}
|
|
765
765
|
await this._loadingScenePromise;
|
|
766
766
|
if (this._isCurrentlyLoading && this.loadingScene?.asset) {
|
|
@@ -62,23 +62,23 @@ export class SpatialTriggerReceiver extends Behaviour {
|
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
currentIntersected: SpatialTrigger[] = [];
|
|
66
|
-
lastIntersected: SpatialTrigger[] = [];
|
|
65
|
+
readonly currentIntersected: SpatialTrigger[] = [];
|
|
66
|
+
readonly lastIntersected: SpatialTrigger[] = [];
|
|
67
67
|
|
|
68
68
|
onEnterTrigger(trigger: SpatialTrigger): void {
|
|
69
69
|
if(debug) console.log("ENTER TRIGGER", this.name, trigger.name, this, trigger);
|
|
70
70
|
trigger.raiseOnEnterEvent(this);
|
|
71
|
-
this.onEnter?.invoke(
|
|
71
|
+
this.onEnter?.invoke();
|
|
72
72
|
}
|
|
73
73
|
onExitTrigger(trigger: SpatialTrigger): void {
|
|
74
|
-
if(debug) console.log("EXIT TRIGGER", this.name, trigger.name,
|
|
74
|
+
if(debug) console.log("EXIT TRIGGER", this.name, trigger.name, );
|
|
75
75
|
trigger.raiseOnExitEvent(this);
|
|
76
|
-
this.onExit?.invoke(
|
|
76
|
+
this.onExit?.invoke();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
onStayTrigger(trigger: SpatialTrigger): void {
|
|
80
80
|
trigger.raiseOnStayEvent(this);
|
|
81
|
-
this.onStay?.invoke(
|
|
81
|
+
this.onStay?.invoke();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MathUtils,Mesh, MeshBasicMaterial, Object3D } from "three";
|
|
1
|
+
import { MathUtils, Mesh, MeshBasicMaterial, Object3D } from "three";
|
|
2
2
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
3
3
|
|
|
4
4
|
import * as params from "../engine/engine_default_parameters.js";
|
|
@@ -26,7 +26,15 @@ export class TransformGizmo extends Behaviour {
|
|
|
26
26
|
@serializable()
|
|
27
27
|
public scaleSnap: number = .25;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Get the underlying three.js TransformControls instance.
|
|
31
|
+
* @returns The TransformControls instance.
|
|
32
|
+
*/
|
|
33
|
+
get control() {
|
|
34
|
+
return this._control;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _control?: TransformControls;
|
|
30
38
|
private orbit?: OrbitControls;
|
|
31
39
|
|
|
32
40
|
/** @internal */
|
|
@@ -35,12 +43,12 @@ export class TransformGizmo extends Behaviour {
|
|
|
35
43
|
|
|
36
44
|
if (!this.context.mainCamera) return;
|
|
37
45
|
|
|
38
|
-
if (!this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
const obj = ("_root" in this.
|
|
46
|
+
if (!this._control) {
|
|
47
|
+
this._control = new TransformControls(this.context.mainCamera, this.context.renderer.domElement);
|
|
48
|
+
this._control.enabled = true;
|
|
49
|
+
this._control.getRaycaster().layers.set(2);
|
|
50
|
+
this._control.size = 1;
|
|
51
|
+
const obj = ("_root" in this._control ? this._control._root : this._control) as Object3D;
|
|
44
52
|
obj.traverse(x => {
|
|
45
53
|
const mesh = x as Mesh;
|
|
46
54
|
mesh.layers.set(2);
|
|
@@ -54,12 +62,12 @@ export class TransformGizmo extends Behaviour {
|
|
|
54
62
|
this.orbit = GameObject.getComponentInParent(this.context.mainCamera, OrbitControls) ?? undefined;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
if (this.
|
|
58
|
-
const obj = this.
|
|
65
|
+
if (this._control) {
|
|
66
|
+
const obj = this._control.getHelper();
|
|
59
67
|
this.context.scene.add(obj);
|
|
60
|
-
this.
|
|
68
|
+
this._control.attach(this.gameObject);
|
|
61
69
|
|
|
62
|
-
this.
|
|
70
|
+
this._control?.addEventListener('dragging-changed', this.onControlChangedEvent);
|
|
63
71
|
window.addEventListener('keydown', this.windowKeyDownListener);
|
|
64
72
|
window.addEventListener('keyup', this.windowKeyUpListener);
|
|
65
73
|
}
|
|
@@ -67,25 +75,25 @@ export class TransformGizmo extends Behaviour {
|
|
|
67
75
|
|
|
68
76
|
/** @internal */
|
|
69
77
|
onDisable() {
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
78
|
+
this._control?.getHelper()?.removeFromParent();
|
|
79
|
+
this._control?.removeEventListener('dragging-changed', this.onControlChangedEvent);
|
|
72
80
|
window.removeEventListener('keydown', this.windowKeyDownListener);
|
|
73
81
|
window.removeEventListener('keyup', this.windowKeyUpListener);
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
enableSnapping() {
|
|
77
|
-
if (this.
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
85
|
+
if (this._control) {
|
|
86
|
+
this._control.setTranslationSnap(this.translationSnap);
|
|
87
|
+
this._control.setRotationSnap(MathUtils.degToRad(this.rotationSnapAngle));
|
|
88
|
+
this._control.setScaleSnap(this.scaleSnap);
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
disableSnapping() {
|
|
85
|
-
if (this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
93
|
+
if (this._control) {
|
|
94
|
+
this._control.setTranslationSnap(null);
|
|
95
|
+
this._control.setRotationSnap(null);
|
|
96
|
+
this._control.setScaleSnap(null);
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
|
|
@@ -104,11 +112,11 @@ export class TransformGizmo extends Behaviour {
|
|
|
104
112
|
|
|
105
113
|
private windowKeyDownListener = (event) => {
|
|
106
114
|
if (!this.enabled) return;
|
|
107
|
-
if (!this.
|
|
115
|
+
if (!this._control) return;
|
|
108
116
|
switch (event.keyCode) {
|
|
109
117
|
|
|
110
118
|
case 81: // Q
|
|
111
|
-
this.
|
|
119
|
+
this._control.setSpace(this._control.space === 'local' ? 'world' : 'local');
|
|
112
120
|
break;
|
|
113
121
|
|
|
114
122
|
case 16: // Shift
|
|
@@ -116,40 +124,40 @@ export class TransformGizmo extends Behaviour {
|
|
|
116
124
|
break;
|
|
117
125
|
|
|
118
126
|
case 87: // W
|
|
119
|
-
this.
|
|
127
|
+
this._control.setMode('translate');
|
|
120
128
|
break;
|
|
121
129
|
|
|
122
130
|
case 69: // E
|
|
123
|
-
this.
|
|
131
|
+
this._control.setMode('rotate');
|
|
124
132
|
break;
|
|
125
133
|
|
|
126
134
|
case 82: // R
|
|
127
|
-
this.
|
|
135
|
+
this._control.setMode('scale');
|
|
128
136
|
break;
|
|
129
137
|
case 187:
|
|
130
138
|
case 107: // +, =, num+
|
|
131
|
-
this.
|
|
139
|
+
this._control.setSize(this._control.size + 0.1);
|
|
132
140
|
break;
|
|
133
141
|
|
|
134
142
|
case 189:
|
|
135
143
|
case 109: // -, _, num-
|
|
136
|
-
this.
|
|
144
|
+
this._control.setSize(Math.max(this._control.size - 0.1, 0.1));
|
|
137
145
|
break;
|
|
138
146
|
|
|
139
147
|
case 88: // X
|
|
140
|
-
this.
|
|
148
|
+
this._control.showX = !this._control.showX;
|
|
141
149
|
break;
|
|
142
150
|
|
|
143
151
|
case 89: // Y
|
|
144
|
-
this.
|
|
152
|
+
this._control.showY = !this._control.showY;
|
|
145
153
|
break;
|
|
146
154
|
|
|
147
155
|
case 90: // Z
|
|
148
|
-
this.
|
|
156
|
+
this._control.showZ = !this._control.showZ;
|
|
149
157
|
break;
|
|
150
158
|
|
|
151
159
|
case 32: // Spacebar
|
|
152
|
-
this.
|
|
160
|
+
this._control.enabled = !this._control.enabled;
|
|
153
161
|
break;
|
|
154
162
|
}
|
|
155
163
|
}
|
|
@@ -6,6 +6,8 @@ import { SerializationContext } from "../../../engine/engine_serialization_core.
|
|
|
6
6
|
import { serializable } from "../../../engine/engine_serialization_decorator.js";
|
|
7
7
|
import { getWorldPosition } from "../../../engine/engine_three_utils.js";
|
|
8
8
|
import { getParam } from "../../../engine/engine_utils.js";
|
|
9
|
+
import { RenderTextureWriter } from "../../../engine/export/gltf/Writers.js";
|
|
10
|
+
import { shouldExport_HideFlags } from "../../../engine/export/utils.js";
|
|
9
11
|
import { registerExportExtensions } from "../../../engine/extensions/index.js";
|
|
10
12
|
import { NEEDLE_components } from "../../../engine/extensions/NEEDLE_components.js";
|
|
11
13
|
import GLTFMeshGPUInstancingExtension from '../../../include/three/EXT_mesh_gpu_instancing_exporter.js';
|
|
@@ -48,8 +50,8 @@ export class GltfExport extends Behaviour {
|
|
|
48
50
|
if (!this.objects || this.objects.length <= 0)
|
|
49
51
|
this.objects = [this.context.scene];
|
|
50
52
|
|
|
51
|
-
const options = {
|
|
52
|
-
binary: this.binary,
|
|
53
|
+
const options = {
|
|
54
|
+
binary: this.binary,
|
|
53
55
|
pivot: GltfExport.calculateCenter(this.objects),
|
|
54
56
|
...opts
|
|
55
57
|
};
|
|
@@ -74,6 +76,15 @@ export class GltfExport extends Behaviour {
|
|
|
74
76
|
|
|
75
77
|
async export(objectsToExport: Object3D[], opts?: ExportOptions): Promise<any> {
|
|
76
78
|
|
|
79
|
+
// -----------------------
|
|
80
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
81
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
82
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
83
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
84
|
+
// TODO: refactor this to use ../engine/export/index exportAsGLTF function
|
|
85
|
+
|
|
86
|
+
// TODO add filtering / tags for what to export and what not < this is implemented in exportAsGLTF, see TODO above
|
|
87
|
+
|
|
77
88
|
if (!objectsToExport || objectsToExport.length <= 0) {
|
|
78
89
|
console.warn("No objects set to export");
|
|
79
90
|
return;
|
|
@@ -82,12 +93,11 @@ export class GltfExport extends Behaviour {
|
|
|
82
93
|
// Instantiate a exporter
|
|
83
94
|
const exporter = new GLTFExporter();
|
|
84
95
|
exporter.register(writer => new GLTFMeshGPUInstancingExtension(writer));
|
|
96
|
+
exporter.register(writer => new RenderTextureWriter(writer));
|
|
85
97
|
registerExportExtensions(exporter, this.context);
|
|
86
98
|
|
|
87
99
|
GltfExport.filterTopmostParent(objectsToExport);
|
|
88
100
|
|
|
89
|
-
// TODO export only worldglb BUT exclude "World" child which contains all build tools
|
|
90
|
-
// TODO add filtering / tags for what to export and what not
|
|
91
101
|
|
|
92
102
|
// https://threejs.org/docs/#examples/en/exporters/GLTFExporter
|
|
93
103
|
const options = {
|
|
@@ -102,7 +112,7 @@ export class GltfExport extends Behaviour {
|
|
|
102
112
|
...opts
|
|
103
113
|
};
|
|
104
114
|
|
|
105
|
-
|
|
115
|
+
const undo = new Array<() => void>();
|
|
106
116
|
|
|
107
117
|
const exportScene = new Object3D();
|
|
108
118
|
// set the pivot position
|
|
@@ -112,7 +122,7 @@ export class GltfExport extends Behaviour {
|
|
|
112
122
|
// add objects for export
|
|
113
123
|
if (debugExport) console.log("EXPORT", objectsToExport);
|
|
114
124
|
objectsToExport.forEach(obj => {
|
|
115
|
-
if (obj) {
|
|
125
|
+
if (obj && shouldExport_HideFlags(obj)) {
|
|
116
126
|
// adding directly does not require us to change parents and mess with the hierarchy actually
|
|
117
127
|
exportScene.children.push(obj);
|
|
118
128
|
// TODO: we should probably be doing this before writing nodes?? apply world scale, position, rotation etc for export only
|
|
@@ -122,6 +132,15 @@ export class GltfExport extends Behaviour {
|
|
|
122
132
|
GameObject.getComponentsInChildren(obj, Renderer).forEach(r => {
|
|
123
133
|
if (GameObject.isActiveInHierarchy(r.gameObject)) r.setInstancingEnabled(false)
|
|
124
134
|
});
|
|
135
|
+
obj.traverse(o => {
|
|
136
|
+
if (!shouldExport_HideFlags(o)) {
|
|
137
|
+
const parent = o.parent;
|
|
138
|
+
o.removeFromParent();
|
|
139
|
+
undo.push(() => {
|
|
140
|
+
if (parent) parent.add(o);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
})
|
|
125
144
|
}
|
|
126
145
|
});
|
|
127
146
|
|
|
@@ -159,6 +178,7 @@ export class GltfExport extends Behaviour {
|
|
|
159
178
|
reject(err);
|
|
160
179
|
}
|
|
161
180
|
finally {
|
|
181
|
+
undo.forEach(u => u());
|
|
162
182
|
if (debugExport) console.log("Finished glTF export.");
|
|
163
183
|
}
|
|
164
184
|
});
|
|
@@ -1174,7 +1174,7 @@ declare type ImageReadbackResult = {
|
|
|
1174
1174
|
imageBitmap?: ImageBitmap;
|
|
1175
1175
|
}
|
|
1176
1176
|
|
|
1177
|
-
/** Reads back a texture from the GPU (can be compressed, a render texture, or
|
|
1177
|
+
/** Reads back a texture from the GPU (can be compressed, a render texture, or anything), optionally applies RGBA colorScale to it, and returns CPU data for further usage.
|
|
1178
1178
|
* Note that there are WebGL / WebGPU rules preventing some use of data between WebGL contexts.
|
|
1179
1179
|
*/
|
|
1180
1180
|
async function decompressGpuTexture( texture, maxTextureSize = Infinity, renderer: WebGLRenderer | null = null, colorScale: Vector4 | undefined = undefined): Promise<ImageReadbackResult> {
|
|
@@ -1204,7 +1204,7 @@ async function decompressGpuTexture( texture, maxTextureSize = Infinity, rendere
|
|
|
1204
1204
|
gl_FragColor = vec4(vUv.xy, 0, 1);
|
|
1205
1205
|
|
|
1206
1206
|
#ifdef IS_SRGB
|
|
1207
|
-
gl_FragColor =
|
|
1207
|
+
gl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );
|
|
1208
1208
|
#else
|
|
1209
1209
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
1210
1210
|
#endif
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { type UsdzBehaviour } from "./extensions/behavior/Behaviour.js";
|
|
2
|
-
export { imageToCanvas, makeNameSafeForUSD, USDZExporter as NeedleUSDZExporter, USDDocument, USDObject, USDWriter,type USDZExporterContext } from "./ThreeUSDZExporter.js";
|
|
2
|
+
export { decompressGpuTexture, imageToCanvas, makeNameSafeForUSD, USDZExporter as NeedleUSDZExporter, USDDocument, USDObject, USDWriter,type USDZExporterContext } from "./ThreeUSDZExporter.js";
|
|
3
3
|
export { USDZExporter } from "./USDZExporter.js";
|