@needle-tools/engine 3.5.7-alpha → 3.5.9-alpha
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 +13 -0
- package/dist/needle-engine.js +5004 -4983
- package/dist/needle-engine.light.js +4834 -4813
- package/dist/needle-engine.light.min.js +146 -146
- package/dist/needle-engine.light.umd.cjs +131 -131
- package/dist/needle-engine.min.js +138 -138
- package/dist/needle-engine.umd.cjs +132 -132
- package/lib/engine/assets/index.js +6 -1
- package/lib/engine/assets/index.js.map +1 -1
- package/lib/engine/engine_element_loading.js +1 -1
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine-components/AudioSource.js +1 -1
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +1 -0
- package/lib/engine-components/ParticleSystem.js +7 -1
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +1 -0
- package/lib/engine-components/SceneSwitcher.js +14 -10
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +1 -0
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +10 -6
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +2 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +9 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js.map +1 -1
- package/lib/engine-components/export/usdz/index.d.ts +2 -0
- package/lib/engine-components/export/usdz/index.js +1 -0
- package/lib/engine-components/export/usdz/index.js.map +1 -1
- package/lib/engine-components/utils/LookAt.js +3 -2
- package/lib/engine-components/utils/LookAt.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/config.cjs +15 -0
- package/plugins/common/license.cjs +31 -0
- package/plugins/next/index.js +1 -0
- package/plugins/next/license.cjs +5 -0
- package/plugins/next/next.js +64 -0
- package/plugins/types/index.d.ts +2 -0
- package/plugins/types/needleConfig.d.ts +12 -0
- package/plugins/types/next.d.ts +0 -0
- package/plugins/types/userconfig.d.ts +27 -0
- package/plugins/vite/alias.js +3 -0
- package/plugins/vite/config.js +4 -2
- package/plugins/vite/copyfiles.js +3 -1
- package/plugins/vite/defines.js +3 -0
- package/plugins/vite/dependency-watcher.js +3 -0
- package/plugins/vite/editor-connection.js +3 -0
- package/plugins/vite/index.js +4 -0
- package/plugins/vite/meta.js +3 -0
- package/plugins/vite/peer.js +3 -0
- package/plugins/vite/reload.js +3 -0
- package/plugins/vite/transform-codegen.js +1 -0
- package/src/engine/assets/index.ts +6 -1
- package/src/engine/engine_element_loading.ts +1 -1
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/ParticleSystem.ts +6 -1
- package/src/engine-components/SceneSwitcher.ts +14 -10
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +12 -6
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +10 -0
- package/src/engine-components/export/usdz/index.ts +3 -1
- package/src/engine-components/utils/LookAt.ts +3 -2
- package/lib/tsconfig.tsbuildinfo +0 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
//@ts-ignore
|
|
3
3
|
import _logo from "./logo.svg"
|
|
4
|
-
|
|
4
|
+
let logoUrl = _logo;
|
|
5
|
+
// in next dev mode the logo is { src: string }
|
|
6
|
+
if (typeof logoUrl === "object") {
|
|
7
|
+
logoUrl = (logoUrl as any).src;
|
|
8
|
+
}
|
|
9
|
+
export const logoSVG: string = logoUrl;
|
|
@@ -178,7 +178,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
178
178
|
|
|
179
179
|
const hasLicense = hasProLicense();
|
|
180
180
|
if (!existing) {
|
|
181
|
-
this._loadingElement.style.position = "
|
|
181
|
+
this._loadingElement.style.position = "absolute";
|
|
182
182
|
this._loadingElement.style.width = "100%";
|
|
183
183
|
this._loadingElement.style.height = "100%";
|
|
184
184
|
this._loadingElement.style.left = "0";
|
|
@@ -197,7 +197,7 @@ export class AudioSource extends Behaviour {
|
|
|
197
197
|
private onVisibilityChanged = () => {
|
|
198
198
|
switch (document.visibilityState) {
|
|
199
199
|
case "hidden":
|
|
200
|
-
if (this.playInBackground === false) {
|
|
200
|
+
if (this.playInBackground === false || utils.isMobileDevice()) {
|
|
201
201
|
this.wasPlaying = this.isPlaying;
|
|
202
202
|
if (this.isPlaying) {
|
|
203
203
|
this.pause();
|
|
@@ -663,6 +663,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
|
|
666
|
+
@serializable()
|
|
667
|
+
playOnAwake: boolean = true;
|
|
668
|
+
|
|
666
669
|
@serializable(ColorOverLifetimeModule)
|
|
667
670
|
readonly colorOverLifetime!: ColorOverLifetimeModule;
|
|
668
671
|
|
|
@@ -881,7 +884,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
881
884
|
this.inheritVelocity.system = this;
|
|
882
885
|
if (this._batchSystem)
|
|
883
886
|
this._batchSystem.visible = true;
|
|
884
|
-
this.
|
|
887
|
+
if (this.playOnAwake)
|
|
888
|
+
this.play();
|
|
889
|
+
this._isPlaying = this.playOnAwake;
|
|
885
890
|
}
|
|
886
891
|
|
|
887
892
|
onDisable() {
|
|
@@ -77,6 +77,10 @@ export class SceneSwitcher extends Behaviour {
|
|
|
77
77
|
|
|
78
78
|
private _preloadScheduler?: PreLoadScheduler;
|
|
79
79
|
|
|
80
|
+
awake(): void {
|
|
81
|
+
if(debug) console.log("SceneSwitcher", this);
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
async start() {
|
|
81
85
|
if (this._currentIndex === -1 && !await this.tryLoadFromQueryParam()) {
|
|
82
86
|
const value = this.context.domElement.getAttribute(ENGINE_ELEMENT_SCENE_ATTRIBUTE_NAME);
|
|
@@ -351,12 +355,12 @@ class PreLoadScheduler {
|
|
|
351
355
|
maxConcurrent: number;
|
|
352
356
|
|
|
353
357
|
private _isRunning: boolean = false;
|
|
354
|
-
private
|
|
355
|
-
private
|
|
358
|
+
private _switcher: SceneSwitcher;
|
|
359
|
+
private _loadTasks: LoadTask[] = [];
|
|
356
360
|
private _maxConcurrentLoads: number = 1;
|
|
357
361
|
|
|
358
362
|
constructor(rooms: SceneSwitcher, ahead: number = 1, behind: number = 1, maxConcurrent: number = 2) {
|
|
359
|
-
this.
|
|
363
|
+
this._switcher = rooms;
|
|
360
364
|
this.maxLoadAhead = ahead;
|
|
361
365
|
this.maxLoadBehind = behind;
|
|
362
366
|
this.maxConcurrent = maxConcurrent;
|
|
@@ -369,7 +373,7 @@ class PreLoadScheduler {
|
|
|
369
373
|
let lastRoom: number = -1;
|
|
370
374
|
let searchDistance: number;
|
|
371
375
|
let searchCall: number;
|
|
372
|
-
const array = this.
|
|
376
|
+
const array = this._switcher.scenes;
|
|
373
377
|
let interval = setInterval(() => {
|
|
374
378
|
if (this.allLoaded()) {
|
|
375
379
|
if (debug)
|
|
@@ -381,8 +385,8 @@ class PreLoadScheduler {
|
|
|
381
385
|
return;
|
|
382
386
|
}
|
|
383
387
|
if (this.canLoadNewScene() === false) return;
|
|
384
|
-
if (lastRoom !== this.
|
|
385
|
-
lastRoom = this.
|
|
388
|
+
if (lastRoom !== this._switcher.currentIndex) {
|
|
389
|
+
lastRoom = this._switcher.currentIndex;
|
|
386
390
|
searchCall = 0;
|
|
387
391
|
searchDistance = 0;
|
|
388
392
|
}
|
|
@@ -396,7 +400,7 @@ class PreLoadScheduler {
|
|
|
396
400
|
// if (roomIndex < 0) roomIndex = array.length + roomIndex;
|
|
397
401
|
if (roomIndex < 0 || roomIndex >= array.length) return;
|
|
398
402
|
const scene = array[roomIndex];
|
|
399
|
-
new LoadTask(roomIndex, scene, this.
|
|
403
|
+
new LoadTask(roomIndex, scene, this._loadTasks);
|
|
400
404
|
}, 200);
|
|
401
405
|
}
|
|
402
406
|
|
|
@@ -405,12 +409,12 @@ class PreLoadScheduler {
|
|
|
405
409
|
}
|
|
406
410
|
|
|
407
411
|
canLoadNewScene(): boolean {
|
|
408
|
-
return this.
|
|
412
|
+
return this._loadTasks.length < this._maxConcurrentLoads;
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
allLoaded(): boolean {
|
|
412
|
-
for (const
|
|
413
|
-
if (
|
|
416
|
+
for (const scene of this._switcher.scenes) {
|
|
417
|
+
if (scene?.isLoaded() === false) return false;
|
|
414
418
|
}
|
|
415
419
|
return true;
|
|
416
420
|
}
|
|
@@ -66,6 +66,13 @@ class USDObject {
|
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
static createEmpty() {
|
|
70
|
+
|
|
71
|
+
const empty = new USDObject( MathUtils.generateUUID(), 'Empty_' + ( USDObject.USDObject_export_id ++ ), new Matrix4() );
|
|
72
|
+
empty.isDynamic = true;
|
|
73
|
+
return empty;
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
constructor( id, name, matrix, mesh: BufferGeometry | null = null, material: Material | null = null, camera: Camera | null = null ) {
|
|
70
77
|
|
|
71
78
|
this.uuid = id;
|
|
@@ -443,7 +450,7 @@ class USDZExporter {
|
|
|
443
450
|
|
|
444
451
|
await invokeAll( context, 'onAfterSerialize' );
|
|
445
452
|
|
|
446
|
-
context.output += buildMaterials( materials, textures );
|
|
453
|
+
context.output += buildMaterials( materials, textures, options.quickLookCompatible );
|
|
447
454
|
|
|
448
455
|
const header = context.document.buildHeader();
|
|
449
456
|
const final = header + '\n' + context.output;
|
|
@@ -1100,7 +1107,7 @@ function buildVector2Array( attribute, count ) {
|
|
|
1100
1107
|
|
|
1101
1108
|
// Materials
|
|
1102
1109
|
|
|
1103
|
-
function buildMaterials( materials, textures ) {
|
|
1110
|
+
function buildMaterials( materials, textures, quickLookCompatible = false ) {
|
|
1104
1111
|
|
|
1105
1112
|
const array: Array<string> = [];
|
|
1106
1113
|
|
|
@@ -1108,7 +1115,7 @@ function buildMaterials( materials, textures ) {
|
|
|
1108
1115
|
|
|
1109
1116
|
const material = materials[ uuid ];
|
|
1110
1117
|
|
|
1111
|
-
array.push( buildMaterial( material, textures ) );
|
|
1118
|
+
array.push( buildMaterial( material, textures, quickLookCompatible ) );
|
|
1112
1119
|
|
|
1113
1120
|
}
|
|
1114
1121
|
|
|
@@ -1121,14 +1128,13 @@ ${array.join( '' )}
|
|
|
1121
1128
|
|
|
1122
1129
|
}
|
|
1123
1130
|
|
|
1124
|
-
function buildMaterial( material: MeshStandardMaterial, textures ) {
|
|
1131
|
+
function buildMaterial( material: MeshStandardMaterial, textures, quickLookCompatible = false ) {
|
|
1125
1132
|
|
|
1126
1133
|
// https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html
|
|
1127
1134
|
|
|
1128
1135
|
const pad = ' ';
|
|
1129
1136
|
const inputs: Array<string> = [];
|
|
1130
1137
|
const samplers: Array<string> = [];
|
|
1131
|
-
const exportForQuickLook = false;
|
|
1132
1138
|
|
|
1133
1139
|
function buildTexture( texture, mapType, color: Color | undefined = undefined, opacity: number | undefined = undefined ) {
|
|
1134
1140
|
|
|
@@ -1151,7 +1157,7 @@ function buildMaterial( material: MeshStandardMaterial, textures ) {
|
|
|
1151
1157
|
|
|
1152
1158
|
// turns out QuickLook is buggy and interprets texture repeat inverted.
|
|
1153
1159
|
// Apple Feedback: FB10036297 and FB11442287
|
|
1154
|
-
if (
|
|
1160
|
+
if ( quickLookCompatible ) {
|
|
1155
1161
|
|
|
1156
1162
|
// This is NOT correct yet in QuickLook, but comes close for a range of models.
|
|
1157
1163
|
// It becomes more incorrect the bigger the offset is
|
|
@@ -110,6 +110,7 @@ export class TriggerModel implements IBehaviorElement {
|
|
|
110
110
|
targetId?: string | Target;
|
|
111
111
|
tokenId?: string;
|
|
112
112
|
type?: string;
|
|
113
|
+
distance?: number;
|
|
113
114
|
|
|
114
115
|
constructor(targetId?: string | Target, id?: string) {
|
|
115
116
|
if (targetId) this.targetId = targetId;
|
|
@@ -127,6 +128,8 @@ export class TriggerModel implements IBehaviorElement {
|
|
|
127
128
|
writer.appendLine(`token info:id = "${this.tokenId}"`);
|
|
128
129
|
if (this.type)
|
|
129
130
|
writer.appendLine(`token type = "${this.type}"`);
|
|
131
|
+
if (typeof this.distance === "number")
|
|
132
|
+
writer.appendLine(`double distance = ${this.distance}`);
|
|
130
133
|
writer.closeBlock();
|
|
131
134
|
}
|
|
132
135
|
}
|
|
@@ -150,6 +153,13 @@ export class TriggerBuilder {
|
|
|
150
153
|
static isTapTrigger(trigger?: TriggerModel) {
|
|
151
154
|
return trigger?.tokenId === "TapGesture";
|
|
152
155
|
}
|
|
156
|
+
|
|
157
|
+
static proximityToCameraTrigger(targetObject: Target, distance: number): TriggerModel {
|
|
158
|
+
const trigger = new TriggerModel(targetObject);
|
|
159
|
+
trigger.tokenId = "ProximityToCamera";
|
|
160
|
+
trigger.distance = distance;
|
|
161
|
+
return trigger;
|
|
162
|
+
}
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
export class GroupActionModel implements IBehaviorElement {
|
|
@@ -55,8 +55,9 @@ export class LookAt extends Behaviour implements UsdzBehaviour {
|
|
|
55
55
|
|
|
56
56
|
// rotate by 90° - counter-rotation on the parent makes sure
|
|
57
57
|
// that without Preliminary Behaviours it still looks right
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const flip = this.invertForward ? -1 : 1;
|
|
59
|
+
parent.matrix.multiply(new Matrix4().makeRotationZ(Math.PI / 2 * flip));
|
|
60
|
+
model.matrix.multiply(new Matrix4().makeRotationZ(-Math.PI / 2 * flip));
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const lookAt = new BehaviorModel("lookat " + this.name,
|