@@ -1,79 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
const url = window.location.search;
|
3
|
-
const urlParams = new URLSearchParams(url);
|
4
|
-
if (!urlParams.has('debugconsole')) return;
|
5
|
-
|
6
|
-
const logNode = document.createElement("pre");
|
7
|
-
logNode.id = "log";
|
8
|
-
const logContainer = document.createElement("div");
|
9
|
-
logContainer.id = "log-container";
|
10
|
-
logContainer.appendChild(logNode);
|
11
|
-
|
12
|
-
window.addEventListener('DOMContentLoaded', (_) => {
|
13
|
-
const arOverlay = document.querySelector('.ar.overlay');
|
14
|
-
if(arOverlay)
|
15
|
-
arOverlay.appendChild(logContainer);
|
16
|
-
else
|
17
|
-
document.body.appendChild(logContainer);
|
18
|
-
});
|
19
|
-
|
20
|
-
rewireLoggingToElement(
|
21
|
-
() => logNode,
|
22
|
-
() => logContainer, true);
|
23
|
-
|
24
|
-
window.onError = function(message, source, lineno, colno, error) {
|
25
|
-
console.error(message, source, lineno, colno, error);
|
26
|
-
}
|
27
|
-
|
28
|
-
console.info("rewired console output");
|
29
|
-
console.info("User Agent: " + navigator.userAgent);
|
30
|
-
|
31
|
-
function rewireLoggingToElement(eleLocator, eleOverflowLocator, autoScroll) {
|
32
|
-
fixLoggingFunc('log');
|
33
|
-
fixLoggingFunc('debug');
|
34
|
-
fixLoggingFunc('warn');
|
35
|
-
fixLoggingFunc('error');
|
36
|
-
fixLoggingFunc('info');
|
37
|
-
|
38
|
-
function fixLoggingFunc(name) {
|
39
|
-
console['old' + name] = console[name];
|
40
|
-
console[name] = function(...args) {
|
41
|
-
const output = produceOutput(name, args);
|
42
|
-
const eleLog = eleLocator();
|
43
|
-
|
44
|
-
if (autoScroll) {
|
45
|
-
const eleContainerLog = eleOverflowLocator();
|
46
|
-
const isScrolledToBottom = eleContainerLog.scrollHeight - eleContainerLog.clientHeight <= eleContainerLog.scrollTop + 1;
|
47
|
-
eleLog.innerHTML += output + "<br>";
|
48
|
-
if (isScrolledToBottom) {
|
49
|
-
eleContainerLog.scrollTop = eleContainerLog.scrollHeight - eleContainerLog.clientHeight;
|
50
|
-
}
|
51
|
-
} else {
|
52
|
-
eleLog.innerHTML += output + "<br>";
|
53
|
-
}
|
54
|
-
|
55
|
-
console['old' + name].apply(undefined, args);
|
56
|
-
};
|
57
|
-
}
|
58
|
-
|
59
|
-
function produceOutput(name, args) {
|
60
|
-
return args.reduce((output, arg) => {
|
61
|
-
try {
|
62
|
-
return output +
|
63
|
-
"<span class=\"log-" + (typeof arg) + " log-" + name + "\">" +
|
64
|
-
(typeof arg === "object" && (JSON || {}).stringify ? JSON.stringify(arg) : arg) +
|
65
|
-
"</span> ";
|
66
|
-
}
|
67
|
-
catch(ex) {
|
68
|
-
console.error("exception when logging: " + ex);
|
69
|
-
}
|
70
|
-
}, '');
|
71
|
-
}
|
72
|
-
}
|
73
|
-
/*
|
74
|
-
setInterval(() => {
|
75
|
-
const method = (['log', 'debug', 'warn', 'error', 'info'][Math.floor(Math.random() * 5)]);
|
76
|
-
console[method](method, 'logging something...');
|
77
|
-
}, 200);
|
78
|
-
*/
|
79
|
-
})();
|
File without changes
|
File without changes
|
File without changes
|
@@ -15,6 +15,7 @@
|
|
15
15
|
* @param isAnimated Whether the object is animated or not
|
16
16
|
*/
|
17
17
|
export function setObjectAnimated(obj: Object3D, animatedBy: object, isAnimated: boolean) {
|
18
|
+
if (!obj) return;
|
18
19
|
if (obj[$objectAnimationKey] === undefined) {
|
19
20
|
if (!isAnimated) return;
|
20
21
|
obj[$objectAnimationKey] = new Set<object>();
|
@@ -30,6 +31,7 @@
|
|
30
31
|
|
31
32
|
/** Get is the object is currently animated. Currently used by the Animator to check if a timeline animationtrack is actively animating an object */
|
32
33
|
export function getObjectAnimated(obj: Object3D): boolean {
|
34
|
+
if (!obj) return false;
|
33
35
|
const set = obj[$objectAnimationKey] as Set<object>;
|
34
36
|
return set !== undefined && set.size > 0;
|
35
37
|
}
|
@@ -157,7 +157,8 @@
|
|
157
157
|
if (!this.animator) return;
|
158
158
|
this.evaluateTransitions();
|
159
159
|
this.updateActiveStates(weight);
|
160
|
-
if (
|
160
|
+
// We want to update the animation mixer even if there is no active state (e.g. in cases where an empty animator controller is assigned and the timeline runs)
|
161
|
+
// if (!this._activeState) return;
|
161
162
|
const dt = this.animator.context.time.deltaTime;
|
162
163
|
if (this.animator.applyRootMotion) {
|
163
164
|
this.rootMotionHandler?.onBeforeUpdate();
|
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
/** Destroys a object
|
102
102
|
* @param instance object to destroy
|
103
|
-
* @param recursive if true, all children will be destroyed as well
|
103
|
+
* @param recursive if true, all children will be destroyed as well. true by default
|
104
104
|
*/
|
105
105
|
public static destroy(instance: Object3D | Component, recursive: boolean = true, isRoot: boolean = true) {
|
106
106
|
return destroy(instance, recursive, isRoot);
|
@@ -520,8 +520,10 @@
|
|
520
520
|
__internalDestroy() {
|
521
521
|
if (this.__destroyed) return;
|
522
522
|
this.__destroyed = true;
|
523
|
-
this.
|
524
|
-
|
523
|
+
if (this.__didAwake) {
|
524
|
+
this.onDestroy?.call(this);
|
525
|
+
this.dispatchEvent(new CustomEvent("destroyed", { detail: this }));
|
526
|
+
}
|
525
527
|
destroyComponentInstance(this as any);
|
526
528
|
}
|
527
529
|
|
@@ -2,10 +2,9 @@
|
|
2
2
|
import { isLocalNetwork } from "../engine_networking_utils.js";
|
3
3
|
import { ContextRegistry } from "../engine_context_registry.js";
|
4
4
|
|
5
|
-
|
6
|
-
|
7
5
|
const debug = getParam("debugdebug");
|
8
|
-
let hide =
|
6
|
+
let hide = true;
|
7
|
+
if(getParam("noerrors")) hide = true;
|
9
8
|
|
10
9
|
const arContainerClassName = "ar";
|
11
10
|
const globalErrorContainerKey = "needle_engine_global_error_container";
|
@@ -21,9 +20,19 @@
|
|
21
20
|
return errorCount;
|
22
21
|
}
|
23
22
|
|
23
|
+
const originalConsoleError = console.error;
|
24
|
+
const patchedConsoleError = function (...args: any[]) {
|
25
|
+
originalConsoleError.apply(console, args);
|
26
|
+
onParseError(args);
|
27
|
+
addLog(LogType.Error, args, null, null);
|
28
|
+
onReceivedError();
|
29
|
+
}
|
30
|
+
|
24
31
|
/** Set false to prevent overlay messages from being shown */
|
25
32
|
export function setAllowOverlayMessages(allow: boolean) {
|
26
33
|
hide = !allow;
|
34
|
+
if (allow) console.error = patchedConsoleError;
|
35
|
+
else console.error = originalConsoleError;
|
27
36
|
}
|
28
37
|
|
29
38
|
export function makeErrorsVisibleForDevelopment() {
|
@@ -33,14 +42,9 @@
|
|
33
42
|
if (isLocal) {
|
34
43
|
if (debug)
|
35
44
|
console.log(window.location.hostname);
|
36
|
-
|
37
|
-
console.error = (...args: any[]) => {
|
38
|
-
error.apply(console, args);
|
39
|
-
onParseError(args);
|
40
|
-
addLog(LogType.Error, args, null, null);
|
41
|
-
onReceivedError();
|
42
|
-
};
|
45
|
+
console.error = patchedConsoleError;
|
43
46
|
window.addEventListener("error", (event) => {
|
47
|
+
if (hide) return;
|
44
48
|
if (!event) return;
|
45
49
|
const message = event.error;
|
46
50
|
if (message === undefined) {
|
@@ -52,6 +56,7 @@
|
|
52
56
|
onReceivedError();
|
53
57
|
}, true);
|
54
58
|
window.addEventListener("unhandledrejection", (event) => {
|
59
|
+
if (hide) return;
|
55
60
|
if (!event) return;
|
56
61
|
if (event.reason)
|
57
62
|
addLog(LogType.Error, event.reason.message, event.reason.stack);
|
@@ -62,6 +67,7 @@
|
|
62
67
|
}
|
63
68
|
}
|
64
69
|
|
70
|
+
|
65
71
|
let errorCount = 0;
|
66
72
|
|
67
73
|
function onReceivedError() {
|
@@ -64,7 +64,8 @@
|
|
64
64
|
try {
|
65
65
|
if (callAwake && componentInstance.__internalAwake) {
|
66
66
|
updateActiveInHierarchyWithoutEventCall(obj);
|
67
|
-
componentInstance.
|
67
|
+
if (componentInstance.activeAndEnabled)
|
68
|
+
componentInstance.__internalAwake();
|
68
69
|
}
|
69
70
|
ComponentLifecycleEvents.dispatchComponentLifecycleEvent(ComponentEvents.Added, componentInstance);
|
70
71
|
}
|
@@ -106,9 +107,8 @@
|
|
106
107
|
}
|
107
108
|
// should we call these methods frame delayed?
|
108
109
|
if (componentInstance.__internalDisable) componentInstance.__internalDisable();
|
109
|
-
if (componentInstance.onDestroy) componentInstance.onDestroy();
|
110
110
|
removeScriptFromContext(componentInstance, componentInstance.context ?? Context.Current);
|
111
|
-
componentInstance.
|
111
|
+
componentInstance.destroy();
|
112
112
|
//@ts-ignore
|
113
113
|
componentInstance.gameObject = null;
|
114
114
|
// console.log("destroyed", index, componentInstance);
|
@@ -121,7 +121,7 @@
|
|
121
121
|
touch-action: none;
|
122
122
|
}
|
123
123
|
:host .content {
|
124
|
-
position:
|
124
|
+
position: absolute;
|
125
125
|
width: 100%;
|
126
126
|
height: 100%;
|
127
127
|
visibility: visible;
|
@@ -109,19 +109,25 @@
|
|
109
109
|
}
|
110
110
|
|
111
111
|
export function destroy(instance: Object3D | Component, recursive: boolean = true, dispose: boolean = false) {
|
112
|
-
|
112
|
+
const allComponents: IComponent[] = [];
|
113
|
+
internalDestroy(instance, recursive, dispose, true, allComponents);
|
114
|
+
for (const comp of allComponents) {
|
115
|
+
comp.gameObject = null!;
|
116
|
+
comp.context = null;
|
117
|
+
}
|
113
118
|
}
|
114
119
|
|
115
|
-
function internalDestroy(instance: Object3D | Component, recursive: boolean = true, dispose: boolean = false, isRoot: boolean = true) {
|
120
|
+
function internalDestroy(instance: Object3D | Component, recursive: boolean = true, dispose: boolean = false, isRoot: boolean = true, allComponents: IComponent[]) {
|
116
121
|
if (instance === null || instance === undefined)
|
117
122
|
return;
|
118
|
-
|
123
|
+
|
119
124
|
const comp = instance as Component;
|
120
125
|
if (comp.isComponent) {
|
126
|
+
allComponents.push(comp);
|
127
|
+
const go = comp.gameObject;
|
121
128
|
comp.__internalDisable();
|
122
129
|
comp.__internalDestroy();
|
123
|
-
comp.gameObject =
|
124
|
-
comp.context = null;
|
130
|
+
comp.gameObject = go;
|
125
131
|
return;
|
126
132
|
}
|
127
133
|
|
@@ -138,7 +144,7 @@
|
|
138
144
|
|
139
145
|
if (recursive && obj.children) {
|
140
146
|
for (const ch of obj.children) {
|
141
|
-
internalDestroy(ch, recursive, dispose, false);
|
147
|
+
internalDestroy(ch, recursive, dispose, false, allComponents);
|
142
148
|
}
|
143
149
|
}
|
144
150
|
|
@@ -147,10 +153,11 @@
|
|
147
153
|
let lastLength = components.length;
|
148
154
|
for (let i = 0; i < components.length; i++) {
|
149
155
|
const comp: Component = components[i];
|
156
|
+
allComponents.push(comp);
|
157
|
+
const go = comp.gameObject;
|
150
158
|
comp.__internalDisable();
|
151
159
|
comp.__internalDestroy();
|
152
|
-
comp.gameObject =
|
153
|
-
comp.context = null;
|
160
|
+
comp.gameObject = go;
|
154
161
|
// if (comp.destroy) {
|
155
162
|
// if (debug) console.log("destroying", comp);
|
156
163
|
// comp.destroy();
|
@@ -36,24 +36,32 @@
|
|
36
36
|
ContextRegistry.registerCallback(ContextEvent.ContextRegistered, evt => {
|
37
37
|
showLicenseInfo(evt.context);
|
38
38
|
sendUsageMessageToAnalyticsBackend();
|
39
|
+
handleForbidden(evt.context);
|
39
40
|
});
|
40
41
|
|
41
42
|
export let runtimeLicenseCheckPromise: Promise<void> | undefined = undefined;
|
43
|
+
let applicationIsForbidden = false;
|
44
|
+
let applicationForbiddenText = "";
|
42
45
|
async function checkLicense() {
|
43
46
|
// Only perform the runtime license check once
|
44
47
|
if (runtimeLicenseCheckPromise) return runtimeLicenseCheckPromise;
|
45
48
|
if (NEEDLE_ENGINE_LICENSE_TYPE === "basic") {
|
46
49
|
try {
|
47
|
-
const licenseUrl = "https://engine.needle.tools/licensing/check";
|
48
|
-
const res = await fetch(licenseUrl);
|
50
|
+
const licenseUrl = "https://engine.needle.tools/licensing/check?location=" + encodeURIComponent(window.location.href) + "&version=" + VERSION + "&generator=" + encodeURIComponent(GENERATOR);
|
51
|
+
const res = await fetch(licenseUrl).catch();
|
49
52
|
if (debug) {
|
50
|
-
const text = await res
|
53
|
+
const text = await res?.text();
|
51
54
|
console.log("Response: \"" + text + "\"\n", res);
|
52
55
|
}
|
53
|
-
if (res
|
54
|
-
|
56
|
+
if (res?.status === 200) {
|
57
|
+
applicationIsForbidden = false;
|
58
|
+
if (debug) console.log("License check succeeded");
|
55
59
|
NEEDLE_ENGINE_LICENSE_TYPE = "pro";
|
56
60
|
}
|
61
|
+
else if (res.status === 403) {
|
62
|
+
applicationIsForbidden = true;
|
63
|
+
applicationForbiddenText = await res.text();
|
64
|
+
}
|
57
65
|
else {
|
58
66
|
if (debug) console.log("License check failed with status " + res.status);
|
59
67
|
}
|
@@ -66,6 +74,53 @@
|
|
66
74
|
}
|
67
75
|
runtimeLicenseCheckPromise = checkLicense();
|
68
76
|
|
77
|
+
async function handleForbidden(ctx: IContext) {
|
78
|
+
function createForbiddenElement() {
|
79
|
+
const div = document.createElement("div");
|
80
|
+
div.className = "needle-forbidden";
|
81
|
+
div.style.cssText = `
|
82
|
+
position: fixed;
|
83
|
+
top: 0;
|
84
|
+
left: 0;
|
85
|
+
width: 100%;
|
86
|
+
height: 100%;
|
87
|
+
pointer-events: all;
|
88
|
+
zIndex: 2147483647;
|
89
|
+
background-color: rgba(0,0,0,0.3);
|
90
|
+
backdrop-filter: blur(10px);
|
91
|
+
webkitBackdropFilter: blur(10px);
|
92
|
+
line-height: 1.5;
|
93
|
+
`;
|
94
|
+
|
95
|
+
const text = document.createElement("div");
|
96
|
+
div.appendChild(text);
|
97
|
+
text.style.cssText = `
|
98
|
+
position: absolute;
|
99
|
+
top: 50%;
|
100
|
+
left: 50%;
|
101
|
+
transform: translate(-50%, -50%);
|
102
|
+
color: white;
|
103
|
+
font-size: 24px;
|
104
|
+
font-family: sans-serif;
|
105
|
+
text-align: center;
|
106
|
+
user-select: none;
|
107
|
+
`;
|
108
|
+
const forbiddenText = applicationForbiddenText?.length > 1 ? applicationForbiddenText : "Needle Engine<br/>This application is not allowed to run on this domain!";
|
109
|
+
text.innerHTML = forbiddenText;
|
110
|
+
return div;
|
111
|
+
}
|
112
|
+
let forbiddenElement = createForbiddenElement();
|
113
|
+
const expectedCSS = forbiddenElement.style.cssText;
|
114
|
+
setInterval(() => {
|
115
|
+
if (applicationIsForbidden === true) {
|
116
|
+
if (forbiddenElement.style.cssText !== expectedCSS) forbiddenElement = createForbiddenElement();
|
117
|
+
if ("isPaused" in ctx) ctx.isPaused = true;
|
118
|
+
if (forbiddenElement.parentNode !== ctx.domElement.shadowRoot)
|
119
|
+
ctx.domElement.shadowRoot?.appendChild(forbiddenElement);
|
120
|
+
}
|
121
|
+
}, 500)
|
122
|
+
}
|
123
|
+
|
69
124
|
async function showLicenseInfo(ctx: IContext) {
|
70
125
|
try {
|
71
126
|
if (hasCommercialLicense() !== true) return onNonCommercialVersionDetected(ctx);
|
@@ -131,6 +186,12 @@
|
|
131
186
|
clearInterval(interval);
|
132
187
|
licenseElement?.remove();
|
133
188
|
style?.remove();
|
189
|
+
// show the logo every x minutes
|
190
|
+
const intervalInMinutes = 5;
|
191
|
+
setTimeout(() => {
|
192
|
+
if (ctx.domElement.parentNode)
|
193
|
+
insertNonCommercialUseHint(ctx);
|
194
|
+
}, 1000 * 60 * intervalInMinutes)
|
134
195
|
}, removeDelay);
|
135
196
|
|
136
197
|
}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import Peer
|
1
|
+
import type Peer from "peerjs";
|
2
|
+
import { type DataConnection } from "peerjs";
|
2
3
|
|
3
4
|
enum MessageType {
|
4
5
|
ConnectionList = "connection-list"
|
@@ -27,7 +28,8 @@
|
|
27
28
|
this.trySetupHost(hostId);
|
28
29
|
}
|
29
30
|
|
30
|
-
private trySetupHost(id: string) {
|
31
|
+
private async trySetupHost(id: string) {
|
32
|
+
const { Peer } = await import("peerjs");
|
31
33
|
const host = new Peer(id);
|
32
34
|
host.on("error", err => {
|
33
35
|
console.error(err);
|
@@ -39,8 +41,8 @@
|
|
39
41
|
});
|
40
42
|
}
|
41
43
|
|
42
|
-
private trySetupClient(hostId: string) {
|
43
|
-
|
44
|
+
private async trySetupClient(hostId: string) {
|
45
|
+
const { Peer } = await import("peerjs");
|
44
46
|
this._client = new Peer();
|
45
47
|
this._client.on("error", err => {
|
46
48
|
console.error("Client error", err);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
const defaultNetworkingBackendUrlProvider = "https://urls.needle.tools/default-networking-backend/index";
|
2
2
|
let serverUrl : string | undefined = "wss://needle-tiny-starter.glitch.me/socket";
|
3
3
|
|
4
|
-
import { Websocket, WebsocketBuilder } from 'websocket-ts';
|
4
|
+
import { type Websocket, type WebsocketBuilder } from 'websocket-ts';
|
5
5
|
// import { Networking } from '../engine-components/Networking.js';
|
6
6
|
import { Context } from './engine_setup.js';
|
7
7
|
import * as utils from "./engine_utils.js";
|
@@ -479,6 +479,7 @@
|
|
479
479
|
}
|
480
480
|
|
481
481
|
console.log("⊡ Connecting to networking backend on\n" + serverUrl)
|
482
|
+
const { WebsocketBuilder } = await import('websocket-ts');
|
482
483
|
const ws = new WebsocketBuilder(serverUrl)
|
483
484
|
.onOpen(() => {
|
484
485
|
this._connectingToWebsocketPromise = null;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import * as THREE from "three";
|
2
1
|
import { Mathf } from "./engine_math.js"
|
3
|
-
import {
|
2
|
+
import { Vector3, Quaternion, Uniform, Texture, AnimationAction, PerspectiveCamera, Object3D, Euler, PlaneGeometry, Scene, Mesh } from "three";
|
3
|
+
import { WebGLRenderer, ShaderMaterial } from "three";
|
4
4
|
import { CircularBuffer } from "./engine_utils.js";
|
5
5
|
|
6
6
|
|
@@ -18,7 +18,6 @@
|
|
18
18
|
obj.quaternion.multiply(flipYQuat);
|
19
19
|
}
|
20
20
|
|
21
|
-
|
22
21
|
const _worldPositions = new CircularBuffer(() => new Vector3(), 100);
|
23
22
|
|
24
23
|
export function getWorldPosition(obj: Object3D, vec: Vector3 | null = null, updateParents: boolean = true): Vector3 {
|
@@ -215,7 +214,7 @@
|
|
215
214
|
|
216
215
|
export class Graphics {
|
217
216
|
private static planeGeometry = new PlaneGeometry(2, 2, 1, 1);
|
218
|
-
private static renderer
|
217
|
+
private static renderer: WebGLRenderer | undefined = undefined;
|
219
218
|
private static perspectiveCam = new PerspectiveCamera();
|
220
219
|
private static scene = new Scene();
|
221
220
|
private static readonly vertex = `
|
@@ -233,11 +232,7 @@
|
|
233
232
|
gl_FragColor = texture2D( map, uv);
|
234
233
|
// gl_FragColor = vec4(uv.xy, 0, 1);
|
235
234
|
}`;
|
236
|
-
private static
|
237
|
-
uniforms: { map: new Uniform(null) },
|
238
|
-
vertexShader: this.vertex,
|
239
|
-
fragmentShader: this.fragment
|
240
|
-
});
|
235
|
+
private static blipMaterial: ShaderMaterial | undefined = undefined;
|
241
236
|
|
242
237
|
static createBlitMaterial(fragment: string): ShaderMaterial {
|
243
238
|
return new ShaderMaterial({
|
@@ -246,18 +241,28 @@
|
|
246
241
|
fragmentShader: fragment
|
247
242
|
});
|
248
243
|
}
|
249
|
-
private static
|
244
|
+
private static mesh: Mesh | undefined = undefined;
|
250
245
|
|
251
246
|
static copyTexture(texture: Texture, blitMaterial?: ShaderMaterial) {
|
252
|
-
const material = blitMaterial ?? this.blipMaterial
|
247
|
+
const material = blitMaterial ?? this.blipMaterial!;
|
253
248
|
material.uniforms.map.value = texture;
|
254
249
|
material.needsUpdate = true;
|
255
250
|
material.uniformsNeedUpdate = true;
|
251
|
+
if (!this.blipMaterial)
|
252
|
+
this.blipMaterial = new ShaderMaterial({
|
253
|
+
uniforms: { map: new Uniform(null) },
|
254
|
+
vertexShader: this.vertex,
|
255
|
+
fragmentShader: this.fragment
|
256
|
+
});
|
257
|
+
if (!this.mesh)
|
258
|
+
this.mesh = new Mesh(this.planeGeometry, this.blipMaterial);
|
256
259
|
const mesh = this.mesh;
|
257
260
|
mesh.material = material;
|
258
261
|
mesh.frustumCulled = false;
|
259
262
|
this.scene.children.length = 0;
|
260
263
|
this.scene.add(mesh);
|
264
|
+
if (!this.renderer)
|
265
|
+
this.renderer = new WebGLRenderer({ antialias: false });
|
261
266
|
this.renderer.setSize(texture.image.width, texture.image.height);
|
262
267
|
this.renderer.clear();
|
263
268
|
this.renderer.render(this.scene, this.perspectiveCam);
|
@@ -8,7 +8,7 @@
|
|
8
8
|
import { IPointerEventHandler, PointerEventData } from "./PointerEvents.js";
|
9
9
|
import { ObjectRaycaster, Raycaster } from "./Raycaster.js";
|
10
10
|
import { InputEvents, PointerEventArgs } from "../../engine/engine_input.js";
|
11
|
-
import { Object3D } from "three";
|
11
|
+
import { Object3D, Vector2 } from "three";
|
12
12
|
import { ICanvasGroup, IGraphic } from "./Interfaces.js";
|
13
13
|
import { getParam } from "../../engine/engine_utils.js";
|
14
14
|
import { UIRaycastUtils } from "./RaycastUtils.js";
|
@@ -251,8 +251,15 @@
|
|
251
251
|
args.isDown = this.context.input.getPointerDown(pointerId);
|
252
252
|
args.isUp = this.context.input.getPointerUp(pointerId);
|
253
253
|
args.isPressed = this.context.input.getPointerPressed(pointerId);
|
254
|
+
const delta = this.context.input.getPointerPositionDelta(pointerId);
|
255
|
+
if (delta) args.positionDelta.copy(delta);
|
254
256
|
if (debug && args.isClicked) console.log("CLICK", pointerId);
|
255
257
|
|
258
|
+
// if the pointer didnt change, theoretically we would need to check the camera as well
|
259
|
+
if (!args.isDown && !args.isUp && !args.isClicked && !args.isPressed && !args.positionDelta.x && !args.positionDelta.y)
|
260
|
+
return
|
261
|
+
|
262
|
+
if(debug) console.log("EventSystem: raycast");
|
256
263
|
const hits = this.performRaycast(null);
|
257
264
|
if (!hits) return;
|
258
265
|
this.lastPointerEvent = args;
|
@@ -435,7 +442,7 @@
|
|
435
442
|
}
|
436
443
|
}
|
437
444
|
|
438
|
-
if (comp.onPointerMove) {
|
445
|
+
if (comp.onPointerMove && args.positionDelta.x !== 0 && args.positionDelta.y !== 0) {
|
439
446
|
comp.onPointerMove(args);
|
440
447
|
}
|
441
448
|
|
@@ -7,14 +7,13 @@
|
|
7
7
|
const debug = getParam("debugexr");
|
8
8
|
|
9
9
|
export class EXT_texture_exr implements GLTFLoaderPlugin {
|
10
|
+
get name() { return "EXT_texture_exr" }
|
10
11
|
|
11
12
|
private parser: GLTFParser;
|
12
|
-
private name: string;
|
13
13
|
|
14
14
|
constructor(parser: GLTFParser) {
|
15
15
|
|
16
16
|
this.parser = parser;
|
17
|
-
this.name = "EXT_texture_exr";
|
18
17
|
if (debug) console.log(parser);
|
19
18
|
|
20
19
|
}
|
@@ -48,4 +47,4 @@
|
|
48
47
|
}
|
49
48
|
|
50
49
|
if (typeof window !== "undefined")
|
51
|
-
window.addEventListener('unhandledrejection', (_event: PromiseRejectionEvent) => {});
|
50
|
+
window.addEventListener('unhandledrejection', (_event: PromiseRejectionEvent) => { });
|
@@ -34,8 +34,10 @@
|
|
34
34
|
const _addedCustomExtension = new Array<ConstructorConcrete<GLTFLoaderPlugin>>();
|
35
35
|
|
36
36
|
export function addCustomExtension(ext: ConstructorConcrete<GLTFLoaderPlugin>) {
|
37
|
-
if (!_addedCustomExtension.includes(ext))
|
37
|
+
if (!_addedCustomExtension.includes(ext)) {
|
38
|
+
if(!ext.name) console.warn("Custom extension has no name", ext);
|
38
39
|
_addedCustomExtension.push(ext);
|
40
|
+
}
|
39
41
|
}
|
40
42
|
export function removeCustomExtension(ext: ConstructorConcrete<GLTFLoaderPlugin>) {
|
41
43
|
const index = _addedCustomExtension.indexOf(ext);
|
@@ -38,6 +38,10 @@
|
|
38
38
|
|
39
39
|
export class NEEDLE_progressive implements GLTFLoaderPlugin {
|
40
40
|
|
41
|
+
get name(): string {
|
42
|
+
return EXTENSION_NAME;
|
43
|
+
}
|
44
|
+
|
41
45
|
static assignTextureLOD(context: Context, source: SourceIdentifier | undefined, material: Material, level: number = 0) {
|
42
46
|
if (!material) return Promise.resolve(null);
|
43
47
|
|
@@ -99,10 +103,6 @@
|
|
99
103
|
});
|
100
104
|
}
|
101
105
|
|
102
|
-
get name(): string {
|
103
|
-
return EXTENSION_NAME;
|
104
|
-
}
|
105
|
-
|
106
106
|
private parser: GLTFParser;
|
107
107
|
private sourceId: SourceIdentifier;
|
108
108
|
private context: Context;
|
@@ -54,6 +54,8 @@
|
|
54
54
|
|
55
55
|
export class NEEDLE_render_objects implements GLTFLoaderPlugin {
|
56
56
|
|
57
|
+
public get name() { return "NEEDLE_render_objects"; }
|
58
|
+
|
57
59
|
private static stencils: { [key: string]: StencilSettingsModel[] } = {};
|
58
60
|
|
59
61
|
static applyStencil(obj?: IRenderer | null) {
|
@@ -107,7 +109,7 @@
|
|
107
109
|
}
|
108
110
|
|
109
111
|
afterRoot(_result: GLTF): Promise<void> | null {
|
110
|
-
|
112
|
+
console.log("AFTER ROOOOOO")
|
111
113
|
const extensions = this.parser.json.extensions;
|
112
114
|
if (extensions) {
|
113
115
|
const ext = extensions[EXTENSION_NAME];
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Vector2 } from "three";
|
1
2
|
import { Input } from "../../engine/engine_input.js";
|
2
3
|
|
3
4
|
export interface IInputEventArgs {
|
@@ -10,6 +11,7 @@
|
|
10
11
|
|
11
12
|
// TODO: should we make this a getter and return the input used state instead? -> this.context.getPointerUsed(this.pointerId);
|
12
13
|
used: boolean = false;
|
14
|
+
positionDelta: Vector2 = new Vector2();
|
13
15
|
|
14
16
|
use() {
|
15
17
|
this.used = true;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { TypeStore } from "./../engine_typestore.js"
|
2
|
-
|
2
|
+
|
3
3
|
// Import types
|
4
4
|
import { __Ignore } from "../../engine-components/codegen/components.js";
|
5
5
|
import { ActionBuilder } from "../../engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js";
|
@@ -217,7 +217,7 @@
|
|
217
217
|
import { XRGrabRendering } from "../../engine-components/webxr/WebXRGrabRendering.js";
|
218
218
|
import { XRRig } from "../../engine-components/webxr/WebXRRig.js";
|
219
219
|
import { XRState } from "../../engine-components/XRFlag.js";
|
220
|
-
|
220
|
+
|
221
221
|
// Register types
|
222
222
|
TypeStore.add("__Ignore", __Ignore);
|
223
223
|
TypeStore.add("ActionBuilder", ActionBuilder);
|
@@ -264,6 +264,19 @@
|
|
264
264
|
}
|
265
265
|
|
266
266
|
async switchScene(scene: AssetReference): Promise<boolean> {
|
267
|
+
if (!(scene instanceof AssetReference)) {
|
268
|
+
const type = typeof scene;
|
269
|
+
if (type === "string") {
|
270
|
+
return this.select(scene);
|
271
|
+
}
|
272
|
+
else if (type === "number") {
|
273
|
+
return this.select(scene);
|
274
|
+
}
|
275
|
+
else {
|
276
|
+
console.error("Cannot switch to scene", scene, "of type", type);
|
277
|
+
return false;
|
278
|
+
}
|
279
|
+
}
|
267
280
|
if (scene === this._currentScene) return true;
|
268
281
|
if (this._currentScene)
|
269
282
|
this._currentScene.unload();
|
@@ -63,7 +63,7 @@
|
|
63
63
|
let hasRoomParameter = false;
|
64
64
|
if (this.urlParameterName) {
|
65
65
|
const val = utils.getParam(this.urlParameterName);
|
66
|
-
if (val && typeof val === "string") {
|
66
|
+
if (val && typeof val === "string" || val === "number") {
|
67
67
|
hasRoomParameter = true;
|
68
68
|
const roomNameParam = utils.sanitizeString(val);
|
69
69
|
this.roomName = roomNameParam;
|
@@ -9,6 +9,10 @@
|
|
9
9
|
|
10
10
|
export class InternalUsageTrackerPlugin implements GLTFLoaderPlugin {
|
11
11
|
|
12
|
+
get name(): string {
|
13
|
+
return "NEEDLE_internal_usage_tracker";
|
14
|
+
}
|
15
|
+
|
12
16
|
static isLoading(object: object) {
|
13
17
|
return InternalUsageTrackerPlugin._loadingProcesses > 0;
|
14
18
|
return object[$loadingId] !== undefined;
|
@@ -139,7 +139,11 @@
|
|
139
139
|
async exportAsync() {
|
140
140
|
|
141
141
|
let name = this.exportFileName ?? this.objectToExport?.name ?? this.name;
|
142
|
-
|
142
|
+
|
143
|
+
if (!hasProLicense()) {
|
144
|
+
if (name !== "") name += "-";
|
145
|
+
name += "MadeWithNeedle";
|
146
|
+
}
|
143
147
|
name += "-" + getFormattedDate(); // seems iOS caches the file in some cases, this ensures we always have a fresh file
|
144
148
|
|
145
149
|
if (!this.link) this.link = ensureQuicklookLinkIsCreated(this.context);
|
@@ -169,7 +173,10 @@
|
|
169
173
|
return;
|
170
174
|
}
|
171
175
|
|
172
|
-
if (!this.objectToExport)
|
176
|
+
if (!this.objectToExport) {
|
177
|
+
console.warn("No object to export", this);
|
178
|
+
return;
|
179
|
+
}
|
173
180
|
|
174
181
|
// trigger progressive textures to be loaded:
|
175
182
|
const renderers = GameObject.getComponentsInChildren(this.objectToExport, Renderer);
|
@@ -255,6 +262,8 @@
|
|
255
262
|
this.link.download = name + ".usdz";
|
256
263
|
this.link.click();
|
257
264
|
|
265
|
+
if (debug) console.log("USDZ generation done. Downloading as " + this.link.download);
|
266
|
+
|
258
267
|
// TODO detect QuickLook availability:
|
259
268
|
// https://webkit.org/blog/8421/viewing-augmented-reality-assets-in-safari-for-ios/#:~:text=inside%20the%20anchor.-,Feature%20Detection,-To%20detect%20support
|
260
269
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
exports.__esModule = true;
|
17
|
+
__exportStar(require("./schemes.js"), exports);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
exports.__esModule = true;
|
3
|
+
exports.tryGetGuid = exports.tryCastBinary = exports.registerBinaryType = exports.binaryIdentifierCasts = void 0;
|
4
|
+
// registry
|
5
|
+
exports.binaryIdentifierCasts = {};
|
6
|
+
function registerBinaryType(identifier, cast) {
|
7
|
+
exports.binaryIdentifierCasts[identifier] = cast;
|
8
|
+
}
|
9
|
+
exports.registerBinaryType = registerBinaryType;
|
10
|
+
// called by networking on receiving a new binary blob
|
11
|
+
// it's just a little helper method so listeners dont have to cast to types every time
|
12
|
+
function tryCastBinary(bin) {
|
13
|
+
var id = bin.getBufferIdentifier();
|
14
|
+
var cast = exports.binaryIdentifierCasts[id];
|
15
|
+
var mod = cast(bin);
|
16
|
+
return mod;
|
17
|
+
}
|
18
|
+
exports.tryCastBinary = tryCastBinary;
|
19
|
+
function tryGetGuid(obj) {
|
20
|
+
if (typeof obj["guid"] === "function") {
|
21
|
+
return obj.guid();
|
22
|
+
}
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
exports.tryGetGuid = tryGetGuid;
|
@@ -0,0 +1,74 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.SyncedCameraModel = void 0;
|
5
|
+
var flatbuffers = require("flatbuffers");
|
6
|
+
var vec3_js_1 = require("./vec3.js");
|
7
|
+
var SyncedCameraModel = /** @class */ (function () {
|
8
|
+
function SyncedCameraModel() {
|
9
|
+
this.bb = null;
|
10
|
+
this.bb_pos = 0;
|
11
|
+
}
|
12
|
+
SyncedCameraModel.prototype.__init = function (i, bb) {
|
13
|
+
this.bb_pos = i;
|
14
|
+
this.bb = bb;
|
15
|
+
return this;
|
16
|
+
};
|
17
|
+
SyncedCameraModel.getRootAsSyncedCameraModel = function (bb, obj) {
|
18
|
+
return (obj || new SyncedCameraModel()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
19
|
+
};
|
20
|
+
SyncedCameraModel.getSizePrefixedRootAsSyncedCameraModel = function (bb, obj) {
|
21
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
22
|
+
return (obj || new SyncedCameraModel()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
23
|
+
};
|
24
|
+
SyncedCameraModel.prototype.userId = function (optionalEncoding) {
|
25
|
+
var offset = this.bb.__offset(this.bb_pos, 4);
|
26
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
27
|
+
};
|
28
|
+
SyncedCameraModel.prototype.guid = function (optionalEncoding) {
|
29
|
+
var offset = this.bb.__offset(this.bb_pos, 6);
|
30
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
31
|
+
};
|
32
|
+
SyncedCameraModel.prototype.dontSave = function () {
|
33
|
+
var offset = this.bb.__offset(this.bb_pos, 8);
|
34
|
+
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
35
|
+
};
|
36
|
+
SyncedCameraModel.prototype.pos = function (obj) {
|
37
|
+
var offset = this.bb.__offset(this.bb_pos, 10);
|
38
|
+
return offset ? (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + offset, this.bb) : null;
|
39
|
+
};
|
40
|
+
SyncedCameraModel.prototype.rot = function (obj) {
|
41
|
+
var offset = this.bb.__offset(this.bb_pos, 12);
|
42
|
+
return offset ? (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + offset, this.bb) : null;
|
43
|
+
};
|
44
|
+
SyncedCameraModel.startSyncedCameraModel = function (builder) {
|
45
|
+
builder.startObject(5);
|
46
|
+
};
|
47
|
+
SyncedCameraModel.addUserId = function (builder, userIdOffset) {
|
48
|
+
builder.addFieldOffset(0, userIdOffset, 0);
|
49
|
+
};
|
50
|
+
SyncedCameraModel.addGuid = function (builder, guidOffset) {
|
51
|
+
builder.addFieldOffset(1, guidOffset, 0);
|
52
|
+
};
|
53
|
+
SyncedCameraModel.addDontSave = function (builder, dontSave) {
|
54
|
+
builder.addFieldInt8(2, +dontSave, +false);
|
55
|
+
};
|
56
|
+
SyncedCameraModel.addPos = function (builder, posOffset) {
|
57
|
+
builder.addFieldStruct(3, posOffset, 0);
|
58
|
+
};
|
59
|
+
SyncedCameraModel.addRot = function (builder, rotOffset) {
|
60
|
+
builder.addFieldStruct(4, rotOffset, 0);
|
61
|
+
};
|
62
|
+
SyncedCameraModel.endSyncedCameraModel = function (builder) {
|
63
|
+
var offset = builder.endObject();
|
64
|
+
return offset;
|
65
|
+
};
|
66
|
+
SyncedCameraModel.finishSyncedCameraModelBuffer = function (builder, offset) {
|
67
|
+
builder.finish(offset);
|
68
|
+
};
|
69
|
+
SyncedCameraModel.finishSizePrefixedSyncedCameraModelBuffer = function (builder, offset) {
|
70
|
+
builder.finish(offset, undefined, true);
|
71
|
+
};
|
72
|
+
return SyncedCameraModel;
|
73
|
+
}());
|
74
|
+
exports.SyncedCameraModel = SyncedCameraModel;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.SyncedTransformModel = void 0;
|
5
|
+
var flatbuffers = require("flatbuffers");
|
6
|
+
var transform_js_1 = require("./transform.js");
|
7
|
+
var SyncedTransformModel = /** @class */ (function () {
|
8
|
+
function SyncedTransformModel() {
|
9
|
+
this.bb = null;
|
10
|
+
this.bb_pos = 0;
|
11
|
+
}
|
12
|
+
SyncedTransformModel.prototype.__init = function (i, bb) {
|
13
|
+
this.bb_pos = i;
|
14
|
+
this.bb = bb;
|
15
|
+
return this;
|
16
|
+
};
|
17
|
+
SyncedTransformModel.getRootAsSyncedTransformModel = function (bb, obj) {
|
18
|
+
return (obj || new SyncedTransformModel()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
19
|
+
};
|
20
|
+
SyncedTransformModel.getSizePrefixedRootAsSyncedTransformModel = function (bb, obj) {
|
21
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
22
|
+
return (obj || new SyncedTransformModel()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
23
|
+
};
|
24
|
+
SyncedTransformModel.prototype.guid = function (optionalEncoding) {
|
25
|
+
var offset = this.bb.__offset(this.bb_pos, 4);
|
26
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* if the transform interpolation should be fast, this is true when the send interval is low and we want to have snappy transforms
|
30
|
+
*/
|
31
|
+
SyncedTransformModel.prototype.fast = function () {
|
32
|
+
var offset = this.bb.__offset(this.bb_pos, 6);
|
33
|
+
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
34
|
+
};
|
35
|
+
SyncedTransformModel.prototype.transform = function (obj) {
|
36
|
+
var offset = this.bb.__offset(this.bb_pos, 8);
|
37
|
+
return offset ? (obj || new transform_js_1.Transform()).__init(this.bb_pos + offset, this.bb) : null;
|
38
|
+
};
|
39
|
+
/**
|
40
|
+
* if the server should not save this info
|
41
|
+
*/
|
42
|
+
SyncedTransformModel.prototype.dontSave = function () {
|
43
|
+
var offset = this.bb.__offset(this.bb_pos, 10);
|
44
|
+
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
45
|
+
};
|
46
|
+
SyncedTransformModel.startSyncedTransformModel = function (builder) {
|
47
|
+
builder.startObject(4);
|
48
|
+
};
|
49
|
+
SyncedTransformModel.addGuid = function (builder, guidOffset) {
|
50
|
+
builder.addFieldOffset(0, guidOffset, 0);
|
51
|
+
};
|
52
|
+
SyncedTransformModel.addFast = function (builder, fast) {
|
53
|
+
builder.addFieldInt8(1, +fast, +false);
|
54
|
+
};
|
55
|
+
SyncedTransformModel.addTransform = function (builder, transformOffset) {
|
56
|
+
builder.addFieldStruct(2, transformOffset, 0);
|
57
|
+
};
|
58
|
+
SyncedTransformModel.addDontSave = function (builder, dontSave) {
|
59
|
+
builder.addFieldInt8(3, +dontSave, +false);
|
60
|
+
};
|
61
|
+
SyncedTransformModel.endSyncedTransformModel = function (builder) {
|
62
|
+
var offset = builder.endObject();
|
63
|
+
return offset;
|
64
|
+
};
|
65
|
+
SyncedTransformModel.finishSyncedTransformModelBuffer = function (builder, offset) {
|
66
|
+
builder.finish(offset);
|
67
|
+
};
|
68
|
+
SyncedTransformModel.finishSizePrefixedSyncedTransformModelBuffer = function (builder, offset) {
|
69
|
+
builder.finish(offset, undefined, true);
|
70
|
+
};
|
71
|
+
return SyncedTransformModel;
|
72
|
+
}());
|
73
|
+
exports.SyncedTransformModel = SyncedTransformModel;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.Transform = void 0;
|
5
|
+
var vec3_js_1 = require("./vec3.js");
|
6
|
+
var Transform = /** @class */ (function () {
|
7
|
+
function Transform() {
|
8
|
+
this.bb = null;
|
9
|
+
this.bb_pos = 0;
|
10
|
+
}
|
11
|
+
Transform.prototype.__init = function (i, bb) {
|
12
|
+
this.bb_pos = i;
|
13
|
+
this.bb = bb;
|
14
|
+
return this;
|
15
|
+
};
|
16
|
+
Transform.prototype.position = function (obj) {
|
17
|
+
return (obj || new vec3_js_1.Vec3()).__init(this.bb_pos, this.bb);
|
18
|
+
};
|
19
|
+
Transform.prototype.rotation = function (obj) {
|
20
|
+
return (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + 12, this.bb);
|
21
|
+
};
|
22
|
+
Transform.prototype.scale = function (obj) {
|
23
|
+
return (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + 24, this.bb);
|
24
|
+
};
|
25
|
+
Transform.sizeOf = function () {
|
26
|
+
return 36;
|
27
|
+
};
|
28
|
+
Transform.createTransform = function (builder, position_x, position_y, position_z, rotation_x, rotation_y, rotation_z, scale_x, scale_y, scale_z) {
|
29
|
+
builder.prep(4, 36);
|
30
|
+
builder.prep(4, 12);
|
31
|
+
builder.writeFloat32(scale_z);
|
32
|
+
builder.writeFloat32(scale_y);
|
33
|
+
builder.writeFloat32(scale_x);
|
34
|
+
builder.prep(4, 12);
|
35
|
+
builder.writeFloat32(rotation_z);
|
36
|
+
builder.writeFloat32(rotation_y);
|
37
|
+
builder.writeFloat32(rotation_x);
|
38
|
+
builder.prep(4, 12);
|
39
|
+
builder.writeFloat32(position_z);
|
40
|
+
builder.writeFloat32(position_y);
|
41
|
+
builder.writeFloat32(position_x);
|
42
|
+
return builder.offset();
|
43
|
+
};
|
44
|
+
return Transform;
|
45
|
+
}());
|
46
|
+
exports.Transform = Transform;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.Vec2 = void 0;
|
5
|
+
var Vec2 = /** @class */ (function () {
|
6
|
+
function Vec2() {
|
7
|
+
this.bb = null;
|
8
|
+
this.bb_pos = 0;
|
9
|
+
}
|
10
|
+
Vec2.prototype.__init = function (i, bb) {
|
11
|
+
this.bb_pos = i;
|
12
|
+
this.bb = bb;
|
13
|
+
return this;
|
14
|
+
};
|
15
|
+
Vec2.prototype.x = function () {
|
16
|
+
return this.bb.readFloat32(this.bb_pos);
|
17
|
+
};
|
18
|
+
Vec2.prototype.y = function () {
|
19
|
+
return this.bb.readFloat32(this.bb_pos + 4);
|
20
|
+
};
|
21
|
+
Vec2.sizeOf = function () {
|
22
|
+
return 8;
|
23
|
+
};
|
24
|
+
Vec2.createVec2 = function (builder, x, y) {
|
25
|
+
builder.prep(4, 8);
|
26
|
+
builder.writeFloat32(y);
|
27
|
+
builder.writeFloat32(x);
|
28
|
+
return builder.offset();
|
29
|
+
};
|
30
|
+
return Vec2;
|
31
|
+
}());
|
32
|
+
exports.Vec2 = Vec2;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.Vec3 = void 0;
|
5
|
+
var Vec3 = /** @class */ (function () {
|
6
|
+
function Vec3() {
|
7
|
+
this.bb = null;
|
8
|
+
this.bb_pos = 0;
|
9
|
+
}
|
10
|
+
Vec3.prototype.__init = function (i, bb) {
|
11
|
+
this.bb_pos = i;
|
12
|
+
this.bb = bb;
|
13
|
+
return this;
|
14
|
+
};
|
15
|
+
Vec3.prototype.x = function () {
|
16
|
+
return this.bb.readFloat32(this.bb_pos);
|
17
|
+
};
|
18
|
+
Vec3.prototype.y = function () {
|
19
|
+
return this.bb.readFloat32(this.bb_pos + 4);
|
20
|
+
};
|
21
|
+
Vec3.prototype.z = function () {
|
22
|
+
return this.bb.readFloat32(this.bb_pos + 8);
|
23
|
+
};
|
24
|
+
Vec3.sizeOf = function () {
|
25
|
+
return 12;
|
26
|
+
};
|
27
|
+
Vec3.createVec3 = function (builder, x, y, z) {
|
28
|
+
builder.prep(4, 12);
|
29
|
+
builder.writeFloat32(z);
|
30
|
+
builder.writeFloat32(y);
|
31
|
+
builder.writeFloat32(x);
|
32
|
+
return builder.offset();
|
33
|
+
};
|
34
|
+
return Vec3;
|
35
|
+
}());
|
36
|
+
exports.Vec3 = Vec3;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.Vec4 = void 0;
|
5
|
+
var Vec4 = /** @class */ (function () {
|
6
|
+
function Vec4() {
|
7
|
+
this.bb = null;
|
8
|
+
this.bb_pos = 0;
|
9
|
+
}
|
10
|
+
Vec4.prototype.__init = function (i, bb) {
|
11
|
+
this.bb_pos = i;
|
12
|
+
this.bb = bb;
|
13
|
+
return this;
|
14
|
+
};
|
15
|
+
Vec4.prototype.x = function () {
|
16
|
+
return this.bb.readFloat32(this.bb_pos);
|
17
|
+
};
|
18
|
+
Vec4.prototype.y = function () {
|
19
|
+
return this.bb.readFloat32(this.bb_pos + 4);
|
20
|
+
};
|
21
|
+
Vec4.prototype.z = function () {
|
22
|
+
return this.bb.readFloat32(this.bb_pos + 8);
|
23
|
+
};
|
24
|
+
Vec4.prototype.w = function () {
|
25
|
+
return this.bb.readFloat32(this.bb_pos + 12);
|
26
|
+
};
|
27
|
+
Vec4.sizeOf = function () {
|
28
|
+
return 16;
|
29
|
+
};
|
30
|
+
Vec4.createVec4 = function (builder, x, y, z, w) {
|
31
|
+
builder.prep(4, 16);
|
32
|
+
builder.writeFloat32(w);
|
33
|
+
builder.writeFloat32(z);
|
34
|
+
builder.writeFloat32(y);
|
35
|
+
builder.writeFloat32(x);
|
36
|
+
return builder.offset();
|
37
|
+
};
|
38
|
+
return Vec4;
|
39
|
+
}());
|
40
|
+
exports.Vec4 = Vec4;
|
@@ -0,0 +1,110 @@
|
|
1
|
+
"use strict";
|
2
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.VrUserStateBuffer = void 0;
|
5
|
+
var flatbuffers = require("flatbuffers");
|
6
|
+
var vec3_js_1 = require("./vec3.js");
|
7
|
+
var vec4_js_1 = require("./vec4.js");
|
8
|
+
var VrUserStateBuffer = /** @class */ (function () {
|
9
|
+
function VrUserStateBuffer() {
|
10
|
+
this.bb = null;
|
11
|
+
this.bb_pos = 0;
|
12
|
+
}
|
13
|
+
VrUserStateBuffer.prototype.__init = function (i, bb) {
|
14
|
+
this.bb_pos = i;
|
15
|
+
this.bb = bb;
|
16
|
+
return this;
|
17
|
+
};
|
18
|
+
VrUserStateBuffer.getRootAsVrUserStateBuffer = function (bb, obj) {
|
19
|
+
return (obj || new VrUserStateBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
20
|
+
};
|
21
|
+
VrUserStateBuffer.getSizePrefixedRootAsVrUserStateBuffer = function (bb, obj) {
|
22
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
23
|
+
return (obj || new VrUserStateBuffer()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
24
|
+
};
|
25
|
+
VrUserStateBuffer.prototype.guid = function (optionalEncoding) {
|
26
|
+
var offset = this.bb.__offset(this.bb_pos, 4);
|
27
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
28
|
+
};
|
29
|
+
VrUserStateBuffer.prototype.time = function () {
|
30
|
+
var offset = this.bb.__offset(this.bb_pos, 6);
|
31
|
+
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
32
|
+
};
|
33
|
+
VrUserStateBuffer.prototype.avatarId = function (optionalEncoding) {
|
34
|
+
var offset = this.bb.__offset(this.bb_pos, 8);
|
35
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
36
|
+
};
|
37
|
+
VrUserStateBuffer.prototype.position = function (obj) {
|
38
|
+
var offset = this.bb.__offset(this.bb_pos, 10);
|
39
|
+
return offset ? (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + offset, this.bb) : null;
|
40
|
+
};
|
41
|
+
VrUserStateBuffer.prototype.rotation = function (obj) {
|
42
|
+
var offset = this.bb.__offset(this.bb_pos, 12);
|
43
|
+
return offset ? (obj || new vec4_js_1.Vec4()).__init(this.bb_pos + offset, this.bb) : null;
|
44
|
+
};
|
45
|
+
VrUserStateBuffer.prototype.scale = function () {
|
46
|
+
var offset = this.bb.__offset(this.bb_pos, 14);
|
47
|
+
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
|
48
|
+
};
|
49
|
+
VrUserStateBuffer.prototype.posLeftHand = function (obj) {
|
50
|
+
var offset = this.bb.__offset(this.bb_pos, 16);
|
51
|
+
return offset ? (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + offset, this.bb) : null;
|
52
|
+
};
|
53
|
+
VrUserStateBuffer.prototype.posRightHand = function (obj) {
|
54
|
+
var offset = this.bb.__offset(this.bb_pos, 18);
|
55
|
+
return offset ? (obj || new vec3_js_1.Vec3()).__init(this.bb_pos + offset, this.bb) : null;
|
56
|
+
};
|
57
|
+
VrUserStateBuffer.prototype.rotLeftHand = function (obj) {
|
58
|
+
var offset = this.bb.__offset(this.bb_pos, 20);
|
59
|
+
return offset ? (obj || new vec4_js_1.Vec4()).__init(this.bb_pos + offset, this.bb) : null;
|
60
|
+
};
|
61
|
+
VrUserStateBuffer.prototype.rotRightHand = function (obj) {
|
62
|
+
var offset = this.bb.__offset(this.bb_pos, 22);
|
63
|
+
return offset ? (obj || new vec4_js_1.Vec4()).__init(this.bb_pos + offset, this.bb) : null;
|
64
|
+
};
|
65
|
+
VrUserStateBuffer.startVrUserStateBuffer = function (builder) {
|
66
|
+
builder.startObject(10);
|
67
|
+
};
|
68
|
+
VrUserStateBuffer.addGuid = function (builder, guidOffset) {
|
69
|
+
builder.addFieldOffset(0, guidOffset, 0);
|
70
|
+
};
|
71
|
+
VrUserStateBuffer.addTime = function (builder, time) {
|
72
|
+
builder.addFieldInt64(1, time, builder.createLong(0, 0));
|
73
|
+
};
|
74
|
+
VrUserStateBuffer.addAvatarId = function (builder, avatarIdOffset) {
|
75
|
+
builder.addFieldOffset(2, avatarIdOffset, 0);
|
76
|
+
};
|
77
|
+
VrUserStateBuffer.addPosition = function (builder, positionOffset) {
|
78
|
+
builder.addFieldStruct(3, positionOffset, 0);
|
79
|
+
};
|
80
|
+
VrUserStateBuffer.addRotation = function (builder, rotationOffset) {
|
81
|
+
builder.addFieldStruct(4, rotationOffset, 0);
|
82
|
+
};
|
83
|
+
VrUserStateBuffer.addScale = function (builder, scale) {
|
84
|
+
builder.addFieldFloat32(5, scale, 0.0);
|
85
|
+
};
|
86
|
+
VrUserStateBuffer.addPosLeftHand = function (builder, posLeftHandOffset) {
|
87
|
+
builder.addFieldStruct(6, posLeftHandOffset, 0);
|
88
|
+
};
|
89
|
+
VrUserStateBuffer.addPosRightHand = function (builder, posRightHandOffset) {
|
90
|
+
builder.addFieldStruct(7, posRightHandOffset, 0);
|
91
|
+
};
|
92
|
+
VrUserStateBuffer.addRotLeftHand = function (builder, rotLeftHandOffset) {
|
93
|
+
builder.addFieldStruct(8, rotLeftHandOffset, 0);
|
94
|
+
};
|
95
|
+
VrUserStateBuffer.addRotRightHand = function (builder, rotRightHandOffset) {
|
96
|
+
builder.addFieldStruct(9, rotRightHandOffset, 0);
|
97
|
+
};
|
98
|
+
VrUserStateBuffer.endVrUserStateBuffer = function (builder) {
|
99
|
+
var offset = builder.endObject();
|
100
|
+
return offset;
|
101
|
+
};
|
102
|
+
VrUserStateBuffer.finishVrUserStateBufferBuffer = function (builder, offset) {
|
103
|
+
builder.finish(offset);
|
104
|
+
};
|
105
|
+
VrUserStateBuffer.finishSizePrefixedVrUserStateBufferBuffer = function (builder, offset) {
|
106
|
+
builder.finish(offset, undefined, true);
|
107
|
+
};
|
108
|
+
return VrUserStateBuffer;
|
109
|
+
}());
|
110
|
+
exports.VrUserStateBuffer = VrUserStateBuffer;
|