@needle-tools/engine 3.5.8-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 +7 -0
- package/dist/needle-engine.js +2660 -2648
- package/dist/needle-engine.light.js +2579 -2567
- package/dist/needle-engine.light.min.js +106 -106
- package/dist/needle-engine.light.umd.cjs +100 -100
- package/dist/needle-engine.min.js +107 -107
- package/dist/needle-engine.umd.cjs +101 -101
- package/lib/engine/engine_element_loading.js +1 -1
- package/lib/engine/engine_element_loading.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/engine_element_loading.ts +1 -1
- 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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export type needleModules = {
|
|
4
|
+
webpack: object | undefined
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type userSettings = {
|
|
8
|
+
/** disable vite.alias modification */
|
|
9
|
+
noAlias: boolean;
|
|
10
|
+
/** disable automatic copying of files to include and output directory (dist) */
|
|
11
|
+
noCopy: boolean;
|
|
12
|
+
/** set to false to tree-shake rapier physics engine to the reduce bundle size */
|
|
13
|
+
useRapier: boolean;
|
|
14
|
+
noDependencyWatcher: boolean;
|
|
15
|
+
/** set to false to suppress editor-sync package installation and connection */
|
|
16
|
+
dontInstallEditor: boolean;
|
|
17
|
+
/** set to false to prevent meta.html modifications (vite only) */
|
|
18
|
+
allowMetaPlugin: boolean;
|
|
19
|
+
/** set to true to prevent injecting peerjs `parcelRequire` global variable declaration */
|
|
20
|
+
noPeer: boolean;
|
|
21
|
+
/** set to true to disable reload plugin */
|
|
22
|
+
noReload: boolean;
|
|
23
|
+
noCodegenTransform: boolean;
|
|
24
|
+
|
|
25
|
+
/** used by nextjs config to forward the webpack module */
|
|
26
|
+
modules: needleModules
|
|
27
|
+
}
|
package/plugins/vite/alias.js
CHANGED
|
@@ -25,6 +25,9 @@ const packages_to_resolve = {
|
|
|
25
25
|
'md5': null,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('../types').userSettings} userSettings
|
|
30
|
+
*/
|
|
28
31
|
export const needleViteAlias = (command, config, userSettings) => {
|
|
29
32
|
|
|
30
33
|
if (config?.noAlias === true || userSettings?.noAlias === true)
|
package/plugins/vite/config.js
CHANGED
|
@@ -17,7 +17,9 @@ export async function loadConfig(path) {
|
|
|
17
17
|
if (existsSync(path)) {
|
|
18
18
|
const text = readFileSync(path, 'utf8');
|
|
19
19
|
if (!text) return null;
|
|
20
|
-
|
|
20
|
+
/**@type {import("../types/needleConfig").needleConfig} */
|
|
21
|
+
const meta = JSON.parse(text);
|
|
22
|
+
return meta;
|
|
21
23
|
}
|
|
22
24
|
else console.error("Could not find config file at " + path);
|
|
23
25
|
return null;
|
|
@@ -51,7 +53,7 @@ export function tryLoadProjectConfig() {
|
|
|
51
53
|
|
|
52
54
|
|
|
53
55
|
/** "assets" -> the directory name inside the output directory to put e.g. glb files into */
|
|
54
|
-
export function builtAssetsDirectory(){
|
|
56
|
+
export function builtAssetsDirectory() {
|
|
55
57
|
return "assets";
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -4,7 +4,9 @@ import { existsSync, statSync, mkdirSync, readdirSync, copyFileSync, mkdir } fro
|
|
|
4
4
|
import { builtAssetsDirectory, tryLoadProjectConfig } from './config.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
/** copy files on build from assets to dist
|
|
7
|
+
/** copy files on build from assets to dist
|
|
8
|
+
* @param {import('../types').userSettings} userSettings
|
|
9
|
+
*/
|
|
8
10
|
export const needleCopyFiles = (command, config, userSettings) => {
|
|
9
11
|
|
|
10
12
|
if (config?.noCopy === true || userSettings?.noCopy === true) {
|
package/plugins/vite/defines.js
CHANGED
|
@@ -9,6 +9,9 @@ import { tryGetNeedleEngineVersion } from "./utils.js";
|
|
|
9
9
|
|
|
10
10
|
// https://vitejs.dev/config/#using-environment-variables-in-config
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @param {import('../types').userSettings} userSettings
|
|
14
|
+
*/
|
|
12
15
|
export const needleDefines = (command, needleEngineConfig, userSettings) => {
|
|
13
16
|
|
|
14
17
|
if (!userSettings) userSettings = {};
|
|
@@ -12,6 +12,9 @@ const editorSyncPackageName = "@needle-tools/editor-sync"
|
|
|
12
12
|
*/
|
|
13
13
|
let editorSyncEnabled = false;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @param {import('../types').userSettings} userSettings
|
|
17
|
+
*/
|
|
15
18
|
export const editorConnection = async (command, config, userSettings, pluginsArray) => {
|
|
16
19
|
if (command === "build") return;
|
|
17
20
|
|
package/plugins/vite/index.js
CHANGED
|
@@ -20,7 +20,11 @@ const defaultUserSettings = {
|
|
|
20
20
|
allowHotReload: true,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('../types').userSettings} userSettings
|
|
25
|
+
*/
|
|
23
26
|
export const needlePlugins = async (command, config, userSettings) => {
|
|
27
|
+
|
|
24
28
|
// ensure we have user settings initialized with defaults
|
|
25
29
|
userSettings = { ...defaultUserSettings, ...userSettings }
|
|
26
30
|
const array = [
|
package/plugins/vite/meta.js
CHANGED
|
@@ -3,6 +3,9 @@ import fs from 'fs';
|
|
|
3
3
|
import { getPosterPath } from './poster.js';
|
|
4
4
|
import { tryGetNeedleEngineVersion } from './utils.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('../types').userSettings} userSettings
|
|
8
|
+
*/
|
|
6
9
|
export const needleMeta = (command, config, userSettings) => {
|
|
7
10
|
|
|
8
11
|
// we can check if this is a build
|
package/plugins/vite/peer.js
CHANGED
|
@@ -3,6 +3,9 @@ const peerjsString = `/* needle: injected fix for peerjs */
|
|
|
3
3
|
window.global = window;
|
|
4
4
|
var parcelRequire;`
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('../types').userSettings} userSettings
|
|
8
|
+
*/
|
|
6
9
|
export const needlePeerjs = (command, config, userSettings) => {
|
|
7
10
|
|
|
8
11
|
if (userSettings.noPeer === true) return;
|
package/plugins/vite/reload.js
CHANGED
|
@@ -11,6 +11,9 @@ const __dirname = path.dirname(__filename);
|
|
|
11
11
|
const filesUsingHotReload = new Set();
|
|
12
12
|
let assetsDirectory = "";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @param {import('../types').userSettings} userSettings
|
|
16
|
+
*/
|
|
14
17
|
export const needleReload = (command, config, userSettings) => {
|
|
15
18
|
if (command === "build") return;
|
|
16
19
|
|
|
@@ -3,6 +3,7 @@ import { builtAssetsDirectory, tryLoadProjectConfig } from './config.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* modify the glb load path in codegen files
|
|
5
5
|
* this is necessary if the assets directory is not the default (changed by the user in needle.config.json)
|
|
6
|
+
* @param {import('../types').userSettings} userSettings
|
|
6
7
|
*/
|
|
7
8
|
export const needleTransformCodegen = (command, config, userSettings) => {
|
|
8
9
|
|
|
@@ -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";
|
|
@@ -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,
|