@needle-tools/engine 4.13.1 → 4.14.0-next.31f837e
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/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-DFcS3P04.js +21 -0
- package/dist/gltf-progressive-8voIgNp_.js +1528 -0
- package/dist/gltf-progressive-BRRBj-nY.umd.cjs +10 -0
- package/dist/gltf-progressive-Dkh3tG4-.min.js +10 -0
- package/dist/loader.worker-C6cXDgR1.js +23 -0
- package/dist/{materialx-BF23AVE8.umd.cjs → materialx-CxlgposR.umd.cjs} +1 -1
- package/dist/{materialx-fkoFuRh3.js → materialx-D66rYPqe.js} +2 -2
- package/dist/{materialx-B9ddsHcF.min.js → materialx-Dx8st96L.min.js} +1 -1
- package/dist/{needle-engine.bundle-tjI5Fq2c.umd.cjs → needle-engine.bundle-BQXG5qbQ.umd.cjs} +138 -145
- package/dist/{needle-engine.bundle-DauZUYl7.js → needle-engine.bundle-Byl5i6zJ.js} +6403 -6164
- package/dist/needle-engine.bundle-D7w0XD7M.min.js +1646 -0
- package/dist/needle-engine.d.ts +251 -23
- package/dist/needle-engine.js +416 -415
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-DdM-tz1j.js → postprocessing-BkSpxpYB.js} +2 -2
- package/dist/{postprocessing-BVNrgYZK.min.js → postprocessing-Ce5-UWiA.min.js} +1 -1
- package/dist/{postprocessing-CI2TjWpu.umd.cjs → postprocessing-DFVElmAh.umd.cjs} +1 -1
- package/dist/{three-BW2s1Yl-.umd.cjs → three-Bad8p1pf.umd.cjs} +46 -46
- package/dist/{three-I__hSXzr.min.js → three-CWn13_u1.min.js} +33 -33
- package/dist/{three-VvRoMeIN.js → three-DFV1-P9z.js} +4209 -4209
- package/dist/{three-examples-BhfOE7NG.js → three-examples-43yqn3mL.js} +1 -1
- package/dist/{three-examples-Bpfu6ke_.umd.cjs → three-examples-CO-tx3Sp.umd.cjs} +1 -1
- package/dist/{three-examples-D8zAE_7t.min.js → three-examples-DKuJVGT4.min.js} +1 -1
- package/dist/{three-mesh-ui-BU55xDxJ.umd.cjs → three-mesh-ui-ChzVOraf.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-C3QbemOV.min.js → three-mesh-ui-DyEA5HQF.min.js} +1 -1
- package/dist/{three-mesh-ui-CcMp-FQm.js → three-mesh-ui-fSAQJxdI.js} +1 -1
- package/dist/{vendor-COVQl0b8.umd.cjs → vendor-B51YffMU.umd.cjs} +1 -1
- package/dist/{vendor-BiyIZ61v.js → vendor-CgpZ5ivC.js} +1 -1
- package/dist/{vendor-DW7zqjuT.min.js → vendor-pe19S9r5.min.js} +1 -1
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.js +12 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_lightdata.js +8 -6
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +47 -0
- package/lib/engine/engine_materialpropertyblock.js +412 -0
- package/lib/engine/engine_materialpropertyblock.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +1 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +171 -14
- package/lib/engine/engine_utils_screenshot.js +65 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.xr.js +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
- package/lib/engine/xr/NeedleXRSession.js +5 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +0 -1
- package/lib/engine-components/ReflectionProbe.js +15 -76
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/RendererLightmap.d.ts +13 -9
- package/lib/engine-components/RendererLightmap.js +68 -81
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js +6 -0
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +1 -0
- package/lib/engine-components/utils/OpenURL.js +1 -0
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +1 -0
- package/lib/engine-components/web/CursorFollow.js +1 -0
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +1 -0
- package/lib/engine-components/web/ScrollFollow.js +1 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +1 -0
- package/lib/engine-components/webxr/WebXR.js +1 -0
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/package.json +4 -4
- package/plugins/vite/build-pipeline.js +16 -2
- package/src/engine/api.ts +1 -0
- package/src/engine/engine_context.ts +17 -3
- package/src/engine/engine_lightdata.ts +8 -6
- package/src/engine/engine_materialpropertyblock.ts +500 -0
- package/src/engine/engine_utils.ts +1 -0
- package/src/engine/engine_utils_screenshot.ts +241 -17
- package/src/engine/engine_utils_screenshot.xr.ts +1 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
- package/src/engine/xr/NeedleXRSession.ts +5 -0
- package/src/engine-components/ContactShadows.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +17 -89
- package/src/engine-components/RendererLightmap.ts +76 -87
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/VideoPlayer.ts +6 -0
- package/src/engine-components/utils/OpenURL.ts +1 -0
- package/src/engine-components/web/CursorFollow.ts +1 -0
- package/src/engine-components/web/ScrollFollow.ts +1 -0
- package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
- package/src/engine-components/webxr/WebXR.ts +1 -0
- package/dist/generateMeshBVH.worker-iyfPIK6R.js +0 -21
- package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
- package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
- package/dist/gltf-progressive-eiJCrjLb.js +0 -1400
- package/dist/loader.worker-C1GG9A7C.js +0 -23
- package/dist/needle-engine.bundle-BNIUpreS.min.js +0 -1653
- package/src/include/three/DragControls.js +0 -232
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { NEEDLE_progressive } from "@needle-tools/gltf-progressive";
|
|
2
|
-
import { Group,
|
|
2
|
+
import { Group, Mesh, Object3D, ShaderMaterial, Texture, Vector2, Vector4 } from "three";
|
|
3
3
|
|
|
4
4
|
import type { Context } from "../engine/engine_setup.js";
|
|
5
5
|
import { getParam } from "../engine/engine_utils.js";
|
|
6
|
+
import { MaterialPropertyBlock } from "../engine/engine_materialpropertyblock.js";
|
|
6
7
|
import { type Renderer } from "./Renderer.js";
|
|
7
8
|
|
|
8
9
|
const debug = getParam("debuglightmaps");
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let cloningCounter = 0;
|
|
13
|
-
|
|
14
|
-
const $lightmapVersion = Symbol("lightmap-material-version");
|
|
11
|
+
const $lightmapKey = Symbol("lightmapKey");
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* This component is automatically added by the {@link Renderer} component if the object has lightmap uvs AND we have a lightmap.
|
|
19
|
-
*
|
|
16
|
+
*
|
|
20
17
|
* @category Rendering
|
|
21
18
|
* @group Components
|
|
22
19
|
*/
|
|
@@ -29,9 +26,13 @@ export class RendererLightmap {
|
|
|
29
26
|
if (tex !== this.lightmapTexture) {
|
|
30
27
|
this.lightmapTexture = tex;
|
|
31
28
|
this.applyLightmap();
|
|
29
|
+
this.updatePropertyBlockTexture();
|
|
32
30
|
if (this.lightmapTexture) {
|
|
33
31
|
NEEDLE_progressive.assignTextureLOD(this.lightmapTexture, 0).then(res => {
|
|
34
|
-
if ((res as Texture)?.isTexture)
|
|
32
|
+
if ((res as Texture)?.isTexture) {
|
|
33
|
+
this.lightmapTexture = res as Texture;
|
|
34
|
+
this.updatePropertyBlockTexture();
|
|
35
|
+
}
|
|
35
36
|
})
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -41,13 +42,12 @@ export class RendererLightmap {
|
|
|
41
42
|
private lightmapScaleOffset: Vector4 = new Vector4(1, 1, 0, 0);
|
|
42
43
|
|
|
43
44
|
private readonly renderer: Renderer;
|
|
44
|
-
private
|
|
45
|
+
private _isApplied: boolean = false;
|
|
45
46
|
|
|
46
47
|
private get context(): Context { return this.renderer.context; }
|
|
47
48
|
private get gameObject() { return this.renderer.gameObject; }
|
|
49
|
+
|
|
48
50
|
private lightmapTexture: Texture | null = null;
|
|
49
|
-
private lightmapScaleOffsetUniform = { value: new Vector4(1, 1, 0, 0) };
|
|
50
|
-
private lightmapUniform: { value: Texture | null } = { value: null };
|
|
51
51
|
|
|
52
52
|
constructor(renderer: Renderer) {
|
|
53
53
|
this.renderer = renderer;
|
|
@@ -60,7 +60,10 @@ export class RendererLightmap {
|
|
|
60
60
|
this.lightmapScaleOffset = lightmapScaleOffset;
|
|
61
61
|
this.lightmapTexture = lightmapTexture;
|
|
62
62
|
NEEDLE_progressive.assignTextureLOD(lightmapTexture, 0).then(res => {
|
|
63
|
-
if ((res as Texture)?.isTexture)
|
|
63
|
+
if ((res as Texture)?.isTexture) {
|
|
64
|
+
this.lightmapTexture = res as Texture;
|
|
65
|
+
this.updatePropertyBlockTexture();
|
|
66
|
+
}
|
|
64
67
|
})
|
|
65
68
|
if (debug == "show") {
|
|
66
69
|
console.log("Lightmap:", this.gameObject.name, lightmapIndex, "\nScaleOffset:", lightmapScaleOffset, "\nTexture:", lightmapTexture)
|
|
@@ -70,18 +73,18 @@ export class RendererLightmap {
|
|
|
70
73
|
this.applyLightmap();
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
updateLightmapUniforms(
|
|
74
|
-
const uniforms = material["uniforms"];
|
|
75
|
-
if (uniforms && uniforms.lightmap) {
|
|
76
|
-
this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset;
|
|
77
|
-
uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
|
|
78
|
-
}
|
|
76
|
+
updateLightmapUniforms(_material: any) {
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
/**
|
|
82
|
-
* Apply the lightmap to the object
|
|
80
|
+
* Apply the lightmap to the object using MaterialPropertyBlock instead of cloning materials.
|
|
81
|
+
* The lightmap texture and its per-object UV transform are set as overrides via PropertyBlock.
|
|
82
|
+
* Three.js reads material.lightMap to determine shader defines and upload uniforms,
|
|
83
|
+
* and uses texture.offset/repeat to compute lightMapTransform in the vertex shader.
|
|
83
84
|
*/
|
|
84
85
|
applyLightmap() {
|
|
86
|
+
if (this._isApplied) return;
|
|
87
|
+
|
|
85
88
|
if (this.gameObject.type === "Object3D") {
|
|
86
89
|
if (debug)
|
|
87
90
|
console.warn("Can not add lightmap. Is this object missing a renderer?", this.gameObject.name);
|
|
@@ -91,23 +94,61 @@ export class RendererLightmap {
|
|
|
91
94
|
const mesh = this.gameObject as unknown as (Mesh | Group);
|
|
92
95
|
this.ensureLightmapUvs(mesh);
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
if (this.lightmapIndex >= 0 && this.lightmapTexture) {
|
|
98
|
+
this.lightmapTexture.channel = 1;
|
|
99
|
+
const so = this.lightmapScaleOffset;
|
|
100
|
+
for (let i = 0; i < this.renderer.sharedMaterials.length; i++) {
|
|
101
|
+
const mat = this.renderer.sharedMaterials[i];
|
|
102
|
+
if (!mat) continue;
|
|
103
|
+
|
|
104
|
+
// If the material doesn't support lightmaps, skip it
|
|
105
|
+
if (mat["lightMap"] === undefined) continue;
|
|
106
|
+
|
|
107
|
+
if (debug) console.log("Setting lightmap on material", mat.name, "for renderer", this.renderer.name);
|
|
108
|
+
|
|
109
|
+
// Use property block to set lightMap with per-object UV transform.
|
|
110
|
+
// The texture transform differentiates cache keys per object and
|
|
111
|
+
// PropertyBlock handles save/restore of the shared texture's offset/repeat.
|
|
112
|
+
const propertyBlock = MaterialPropertyBlock.get(this.gameObject);
|
|
113
|
+
propertyBlock.setOverride("lightMap", this.lightmapTexture, {
|
|
114
|
+
offset: new Vector2(so.z, 1 - so.y - so.w),
|
|
115
|
+
repeat: new Vector2(so.x, so.y)
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
(mat as any)[$lightmapKey] = true;
|
|
101
119
|
}
|
|
120
|
+
|
|
121
|
+
this._isApplied = true;
|
|
102
122
|
}
|
|
123
|
+
}
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
/** Update the lightMap override on all property blocks (e.g. after LOD swap) */
|
|
126
|
+
private updatePropertyBlockTexture() {
|
|
127
|
+
if (!this._isApplied || !this.lightmapTexture) return;
|
|
128
|
+
this.lightmapTexture.channel = 1;
|
|
129
|
+
const so = this.lightmapScaleOffset;
|
|
130
|
+
const propertyBlock = MaterialPropertyBlock.get(this.gameObject);
|
|
131
|
+
propertyBlock.setOverride("lightMap", this.lightmapTexture, {
|
|
132
|
+
offset: new Vector2(so.z, 1 - so.y - so.w),
|
|
133
|
+
repeat: new Vector2(so.x, so.y)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Remove the lightmap from the object
|
|
139
|
+
*/
|
|
140
|
+
onUnset() {
|
|
141
|
+
for (let i = 0; i < this.renderer.sharedMaterials.length; i++) {
|
|
142
|
+
const mat = this.renderer.sharedMaterials[i];
|
|
143
|
+
if (mat) {
|
|
144
|
+
delete (mat as any)[$lightmapKey];
|
|
109
145
|
}
|
|
110
146
|
}
|
|
147
|
+
const block = MaterialPropertyBlock.get(this.gameObject);
|
|
148
|
+
if (block) {
|
|
149
|
+
block.clearOverride("lightMap");
|
|
150
|
+
block.clearOverride("lightMapIntensity");
|
|
151
|
+
}
|
|
111
152
|
}
|
|
112
153
|
|
|
113
154
|
private ensureLightmapUvs(object: Object3D | Group | Mesh) {
|
|
@@ -123,59 +164,8 @@ export class RendererLightmap {
|
|
|
123
164
|
}
|
|
124
165
|
}
|
|
125
166
|
|
|
126
|
-
private ensureLightmapMaterial(material: Material, index: number) {
|
|
127
|
-
if (!material.userData) material.userData = {};
|
|
128
|
-
// if (material instanceof MeshPhysicalMaterial) {
|
|
129
|
-
// return material;
|
|
130
|
-
// }
|
|
131
|
-
// check if the material version has changed and only then clone the material
|
|
132
|
-
if (this.clonedMaterials[index] !== material) {
|
|
133
|
-
if (debug) {
|
|
134
|
-
++cloningCounter;
|
|
135
|
-
if (cloningCounter++ < 1000) {
|
|
136
|
-
console.warn(`Cloning material for lightmap ${this.renderer.name}: '${material.name}'`);
|
|
137
|
-
}
|
|
138
|
-
else if (cloningCounter === 1000) {
|
|
139
|
-
console.warn(`Further material cloning for lightmaps suppressed to avoid flooding the console.`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const mat: Material = material.clone();
|
|
143
|
-
if (!mat.name?.includes("(lightmap)")) mat.name = material.name + " (lightmap)";
|
|
144
|
-
material = mat;
|
|
145
|
-
material.onBeforeCompile = this.onBeforeCompile;
|
|
146
|
-
this.clonedMaterials[index] = material;
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
return material;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private assignLightmapTexture(material: MaterialWithLightmap) {
|
|
153
|
-
if (!material) return;
|
|
154
|
-
if (material instanceof MeshPhysicalMaterial && material.transmission > 0) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const hasChanged = material.lightMap !== this.lightmapTexture || material[$lightmapVersion] !== material.version;
|
|
158
|
-
if (!hasChanged) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (debug) console.log(`Assigning lightmap texture ${this.renderer.name}: '${material.name}' (${material.version} ${material[$lightmapVersion]})`);
|
|
163
|
-
|
|
164
|
-
// assign the lightmap
|
|
165
|
-
material.lightMap = this.lightmapTexture;
|
|
166
|
-
material.needsUpdate = true;
|
|
167
|
-
// store the version of the material
|
|
168
|
-
material[$lightmapVersion] = material.version;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
private onBeforeCompile = (shader: WebGLProgramParametersWithUniforms, _) => {
|
|
172
|
-
if (debug === "verbose") console.log("Lightmaps, before compile\n", shader)
|
|
173
|
-
this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset;
|
|
174
|
-
this.lightmapUniform.value = this.lightmapTexture;
|
|
175
|
-
shader.uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
167
|
private setLightmapDebugMaterial() {
|
|
168
|
+
const so = this.lightmapScaleOffset;
|
|
179
169
|
|
|
180
170
|
// debug lightmaps
|
|
181
171
|
this.gameObject["material"] = new ShaderMaterial({
|
|
@@ -190,7 +180,6 @@ export class RendererLightmap {
|
|
|
190
180
|
fragmentShader: `
|
|
191
181
|
uniform sampler2D lightMap;
|
|
192
182
|
uniform float lightMapIntensity;
|
|
193
|
-
uniform vec4 lightmapScaleOffset;
|
|
194
183
|
varying vec2 vUv1;
|
|
195
184
|
|
|
196
185
|
// took from threejs 05fc79cd52b79e8c3e8dec1e7dca72c5c39983a4
|
|
@@ -199,8 +188,8 @@ export class RendererLightmap {
|
|
|
199
188
|
}
|
|
200
189
|
|
|
201
190
|
void main() {
|
|
202
|
-
vec2 lUv = vUv1.xy *
|
|
203
|
-
|
|
191
|
+
vec2 lUv = vUv1.xy * vec2(${so.x.toFixed(6)}, ${so.y.toFixed(6)}) + vec2(${so.z.toFixed(6)}, ${(1 - so.y - so.w).toFixed(6)});
|
|
192
|
+
|
|
204
193
|
vec4 lightMapTexel = texture2D( lightMap, lUv);
|
|
205
194
|
gl_FragColor = lightMapTexel;
|
|
206
195
|
gl_FragColor.a = 1.;
|
|
@@ -209,4 +198,4 @@ export class RendererLightmap {
|
|
|
209
198
|
defines: { USE_LIGHTMAP: '' }
|
|
210
199
|
});
|
|
211
200
|
}
|
|
212
|
-
}
|
|
201
|
+
}
|
|
@@ -6,12 +6,12 @@ import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
|
6
6
|
import { getTempVector } from "../engine/engine_three_utils.js";
|
|
7
7
|
import { getParam } from "../engine/engine_utils.js";
|
|
8
8
|
import { USDObject, USDZExporterContext } from "./api.js";
|
|
9
|
+
import type { Camera } from "./Camera.js";
|
|
9
10
|
import { Behaviour } from "./Component.js";
|
|
10
11
|
import { IUSDExporterExtension } from "./export/usdz/Extension.js";
|
|
11
12
|
import { USDZExporter } from "./export/usdz/USDZExporter.js";
|
|
12
|
-
import { Renderer } from "./Renderer.js";
|
|
13
|
-
import type { Camera } from "./Camera.js";
|
|
14
13
|
import type { OrbitControls } from "./OrbitControls.js";
|
|
14
|
+
import { Renderer } from "./Renderer.js";
|
|
15
15
|
|
|
16
16
|
const debugSeeThrough = getParam("debugseethrough");
|
|
17
17
|
|
|
@@ -604,11 +604,17 @@ export class VideoPlayer extends Behaviour {
|
|
|
604
604
|
const videoMaterial = this._videoMaterial as any;
|
|
605
605
|
|
|
606
606
|
if (!this.targetMaterialProperty) {
|
|
607
|
+
if (debug && videoMaterial[fieldName] === undefined) {
|
|
608
|
+
console.warn(`The target material does not have a '${fieldName}' property, video might not render correctly.`);
|
|
609
|
+
}
|
|
607
610
|
videoMaterial[fieldName] = this._videoTexture;
|
|
608
611
|
}
|
|
609
612
|
else {
|
|
610
613
|
switch (this.targetMaterialProperty) {
|
|
611
614
|
default:
|
|
615
|
+
if (debug && videoMaterial[this.targetMaterialProperty] === undefined) {
|
|
616
|
+
console.warn(`The target material does not have a '${this.targetMaterialProperty}' property, video might not render correctly.`);
|
|
617
|
+
}
|
|
612
618
|
videoMaterial[fieldName] = this._videoTexture;
|
|
613
619
|
break;
|
|
614
620
|
// doesnt render:
|
|
@@ -19,6 +19,7 @@ export enum OpenURLMode {
|
|
|
19
19
|
* OpenURL behaviour opens a URL in a new tab or window when the object (or any if it's children) is clicked.
|
|
20
20
|
*
|
|
21
21
|
* @category Interactivity
|
|
22
|
+
* @category Web
|
|
22
23
|
* @group Components
|
|
23
24
|
*/
|
|
24
25
|
export class OpenURL extends Behaviour implements IPointerClickHandler {
|
|
@@ -22,13 +22,22 @@ import { Behaviour } from "../Component.js";
|
|
|
22
22
|
const debug = getParam("debugarcamera");
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* WebARCameraBackground is a component that allows to display the camera feed as a background in an AR session to more easily blend the real world with the virtual world or applying effects to the camera feed.
|
|
26
|
-
*
|
|
25
|
+
* WebARCameraBackground is a component that allows to display the camera feed as a background in an AR session to more easily blend the real world with the virtual world or applying effects to the camera feed.
|
|
26
|
+
*
|
|
27
|
+
* This component automatically requests `camera-access` permission when entering AR mode, which is required to:
|
|
28
|
+
* - Display the real-world camera feed as a background
|
|
29
|
+
* - Include the camera feed in AR screenshots taken with {@link screenshot2}
|
|
30
|
+
*
|
|
31
|
+
* **Note**: If you want to take AR screenshots with the camera feed but don't need to display it as a background,
|
|
32
|
+
* you can still add this component to your scene (it will request camera access) or manually request the
|
|
33
|
+
* `camera-access` feature in your `onBeforeXR` method.
|
|
34
|
+
*
|
|
27
35
|
* - Example: https://samples.needle.tools/ar-camera-background
|
|
28
|
-
*
|
|
36
|
+
*
|
|
29
37
|
* @summary Displays the camera feed as background in WebAR sessions
|
|
30
38
|
* @category XR
|
|
31
39
|
* @group Components
|
|
40
|
+
* @see {@link screenshot2} for taking screenshots in AR (requires camera access for camera feed compositing)
|
|
32
41
|
*/
|
|
33
42
|
export class WebARCameraBackground extends Behaviour {
|
|
34
43
|
|
|
@@ -59,6 +59,7 @@ const debugQuicklook = getParam("debugusdz");
|
|
|
59
59
|
* @see {@link XRControllerMovement} for VR locomotion
|
|
60
60
|
* @see {@link WebARSessionRoot} for AR session configuration
|
|
61
61
|
* @see {@link Avatar} for networked user avatars
|
|
62
|
+
* @see {@link screenshot2} for taking screenshots in XR (including AR camera feed compositing)
|
|
62
63
|
* @link https://engine.needle.tools/docs/xr.html
|
|
63
64
|
* @link https://engine.needle.tools/samples/?overlay=samples&tag=xr
|
|
64
65
|
* @link https://engine.needle.tools/samples/collaborative-sandbox
|