lunchboxjs 0.2.1020 → 2.0.0-beta.1

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.
Files changed (41) hide show
  1. package/dist/lunchboxjs.cjs +46 -0
  2. package/dist/lunchboxjs.d.ts +1 -0
  3. package/dist/lunchboxjs.js +1632 -1962
  4. package/dist/lunchboxjs.umd.cjs +46 -0
  5. package/package.json +36 -81
  6. package/LICENSE.md +0 -7
  7. package/README.md +0 -17
  8. package/dist/lunchboxjs.es.d.ts +0 -1
  9. package/dist/lunchboxjs.min.js +0 -1
  10. package/dist/lunchboxjs.module.js +0 -1924
  11. package/dist/lunchboxjs.umd.d.ts +0 -1
  12. package/src/components/LunchboxEventHandlers.tsx +0 -237
  13. package/src/components/LunchboxWrapper/LunchboxScene.tsx +0 -8
  14. package/src/components/LunchboxWrapper/LunchboxWrapper.tsx +0 -341
  15. package/src/components/LunchboxWrapper/prepCanvas.ts +0 -55
  16. package/src/components/LunchboxWrapper/resizeCanvas.ts +0 -41
  17. package/src/components/autoGeneratedComponents.ts +0 -175
  18. package/src/components/index.ts +0 -31
  19. package/src/core/createNode.ts +0 -71
  20. package/src/core/extend.ts +0 -25
  21. package/src/core/index.ts +0 -7
  22. package/src/core/instantiateThreeObject/index.ts +0 -37
  23. package/src/core/instantiateThreeObject/processProps.ts +0 -40
  24. package/src/core/interaction.ts +0 -55
  25. package/src/core/minidom.ts +0 -256
  26. package/src/core/update.ts +0 -149
  27. package/src/core/updateObjectProp.ts +0 -153
  28. package/src/index.ts +0 -400
  29. package/src/keys.ts +0 -31
  30. package/src/nodeOps/createElement.ts +0 -34
  31. package/src/nodeOps/index.ts +0 -83
  32. package/src/nodeOps/insert.ts +0 -165
  33. package/src/nodeOps/remove.ts +0 -32
  34. package/src/plugins/bridge/BridgeComponent.tsx +0 -60
  35. package/src/plugins/bridge/bridge.ts +0 -9
  36. package/src/types.ts +0 -186
  37. package/src/utils/find.ts +0 -24
  38. package/src/utils/get.ts +0 -18
  39. package/src/utils/index.ts +0 -60
  40. package/src/utils/isNumber.ts +0 -87
  41. package/src/utils/set.ts +0 -14
@@ -1,2007 +1,1677 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('three')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'three'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Lunchbox = {}, global.vue, global.three));
5
- })(this, (function (exports, vue, THREE) { 'use strict';
6
-
7
- function _interopNamespaceDefault(e) {
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
1
+ import * as m from "three";
2
+ const Ou = [
3
+ // ORDER MATTERS HERE!
4
+ // Place the objects most likely to wrap other objects at the beginning of the list.
5
+ // Main wrappers
6
+ "WebGLRenderer",
7
+ "Scene",
8
+ "Group",
9
+ // Secondary wrappers (objects, meshes, etc)
10
+ "Object3D",
11
+ "Mesh",
12
+ "Sprite",
13
+ // Tertiary items (individual geometries, materials, etc)
14
+ // Geometries
15
+ "BoxGeometry",
16
+ "BufferGeometry",
17
+ "CircleGeometry",
18
+ "ConeGeometry",
19
+ "CylinderGeometry",
20
+ "DodecahedronGeometry",
21
+ "ExtrudeGeometry",
22
+ "IcosahedronGeometry",
23
+ "InstancedBufferGeometry",
24
+ "LatheGeometry",
25
+ "OctahedronGeometry",
26
+ "PlaneGeometry",
27
+ "PolyhedronGeometry",
28
+ "RingGeometry",
29
+ "ShapeGeometry",
30
+ "SphereGeometry",
31
+ "TetrahedronGeometry",
32
+ "TorusGeometry",
33
+ "TorusKnotGeometry",
34
+ "TubeGeometry",
35
+ "WireframeGeometry",
36
+ // Materials
37
+ "PointsMaterial",
38
+ "ShaderMaterial",
39
+ "ShadowMaterial",
40
+ "SpriteMaterial",
41
+ "MeshToonMaterial",
42
+ "MeshBasicMaterial",
43
+ "MeshDepthMaterial",
44
+ "MeshPhongMaterial",
45
+ "LineBasicMaterial",
46
+ "RawShaderMaterial",
47
+ "MeshMatcapMaterial",
48
+ "MeshNormalMaterial",
49
+ "LineDashedMaterial",
50
+ "MeshLambertMaterial",
51
+ "MeshStandardMaterial",
52
+ "MeshDistanceMaterial",
53
+ "MeshPhysicalMaterial",
54
+ // Lights
55
+ "Light",
56
+ "SpotLight",
57
+ "SpotLightHelper",
58
+ "PointLight",
59
+ "PointLightHelper",
60
+ "AmbientLight",
61
+ "RectAreaLight",
62
+ "HemisphereLight",
63
+ "HemisphereLightHelper",
64
+ "DirectionalLight",
65
+ "DirectionalLightHelper",
66
+ // Cameras
67
+ "CubeCamera",
68
+ "ArrayCamera",
69
+ "StereoCamera",
70
+ "PerspectiveCamera",
71
+ "OrthographicCamera",
72
+ // Textures
73
+ "Texture",
74
+ "CubeTexture",
75
+ "DataTexture",
76
+ "DepthTexture",
77
+ "VideoTexture",
78
+ "CanvasTexture",
79
+ "CompressedTexture",
80
+ // Misc
81
+ "CatmullRomCurve3",
82
+ "Points",
83
+ "Raycaster",
84
+ "CameraHelper",
85
+ "Color"
86
+ ];
87
+ /**
88
+ * @license
89
+ * Copyright 2019 Google LLC
90
+ * SPDX-License-Identifier: BSD-3-Clause
91
+ */
92
+ const Q = globalThis, lu = Q.ShadowRoot && (Q.ShadyCSS === void 0 || Q.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, du = Symbol(), yu = /* @__PURE__ */ new WeakMap();
93
+ let Lu = class {
94
+ constructor(u, e, r) {
95
+ if (this._$cssResult$ = !0, r !== du)
96
+ throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
97
+ this.cssText = u, this.t = e;
98
+ }
99
+ get styleSheet() {
100
+ let u = this.o;
101
+ const e = this.t;
102
+ if (lu && u === void 0) {
103
+ const r = e !== void 0 && e.length === 1;
104
+ r && (u = yu.get(e)), u === void 0 && ((this.o = u = new CSSStyleSheet()).replaceSync(this.cssText), r && yu.set(e, u));
22
105
  }
23
-
24
- var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
25
-
26
- function find(target) {
27
- target = vue.isRef(target) ? target.value : target;
28
- // handle standard lunchbox node
29
- if (isLunchboxStandardNode(target)) {
30
- return target?.instance;
31
- }
32
- // handle component
33
- if (isLunchboxComponent(target)) {
34
- return target?.$el?.instance;
35
- }
36
- // handle vnode
37
- if (vue.isVNode(target)) {
38
- return target.el?.instance;
39
- }
40
- return null;
106
+ return u;
107
+ }
108
+ toString() {
109
+ return this.cssText;
110
+ }
111
+ };
112
+ const Ku = (t) => new Lu(typeof t == "string" ? t : t + "", void 0, du), Xu = (t, ...u) => {
113
+ const e = t.length === 1 ? t[0] : u.reduce((r, D, s) => r + ((i) => {
114
+ if (i._$cssResult$ === !0)
115
+ return i.cssText;
116
+ if (typeof i == "number")
117
+ return i;
118
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + i + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
119
+ })(D) + t[s + 1], t[0]);
120
+ return new Lu(e, t, du);
121
+ }, Yu = (t, u) => {
122
+ if (lu)
123
+ t.adoptedStyleSheets = u.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
124
+ else
125
+ for (const e of u) {
126
+ const r = document.createElement("style"), D = Q.litNonce;
127
+ D !== void 0 && r.setAttribute("nonce", D), r.textContent = e.cssText, t.appendChild(r);
41
128
  }
42
-
43
- const get = (obj, path, defValue) => {
44
- // If path is not defined or it has false value
45
- if (!path) return undefined;
46
- // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
47
- // Regex explained: https://regexr.com/58j0k
48
- const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
49
- // Find value
50
- const result = pathArray?.reduce((prevObj, key) => prevObj && prevObj[key], obj);
51
- // If found value is undefined return default value; otherwise return the value
52
- return result === undefined ? defValue : result;
53
- };
54
-
55
- const buildIsNumber = () => {
56
- /**
57
- * lodash (Custom Build) <https://lodash.com/>
58
- * Build: `lodash modularize exports="npm" -o ./`
59
- * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
60
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
61
- * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
62
- * Available under MIT license <https://lodash.com/license>
63
- */
64
- /** `Object#toString` result references. */
65
- const numberTag = '[object Number]';
66
- /** Used for built-in method references. */
67
- const objectProto = Object.prototype;
68
- /**
69
- * Used to resolve the
70
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
71
- * of values.
72
- */
73
- const objectToString = objectProto.toString;
74
- /**
75
- * Checks if `value` is object-like. A value is object-like if it's not `null`
76
- * and has a `typeof` result of "object".
77
- *
78
- * @static
79
- * @memberOf _
80
- * @since 4.0.0
81
- * @category Lang
82
- * @param {*} value The value to check.
83
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
84
- * @example
85
- *
86
- * _.isObjectLike({});
87
- * // => true
88
- *
89
- * _.isObjectLike([1, 2, 3]);
90
- * // => true
91
- *
92
- * _.isObjectLike(_.noop);
93
- * // => false
94
- *
95
- * _.isObjectLike(null);
96
- * // => false
97
- */
98
- function isObjectLike(value) {
99
- return !!value && typeof value == 'object';
129
+ }, gu = lu ? (t) => t : (t) => t instanceof CSSStyleSheet ? ((u) => {
130
+ let e = "";
131
+ for (const r of u.cssRules)
132
+ e += r.cssText;
133
+ return Ku(e);
134
+ })(t) : t;
135
+ /**
136
+ * @license
137
+ * Copyright 2017 Google LLC
138
+ * SPDX-License-Identifier: BSD-3-Clause
139
+ */
140
+ const { is: Qu, defineProperty: ue, getOwnPropertyDescriptor: ee, getOwnPropertyNames: te, getOwnPropertySymbols: re, getPrototypeOf: De } = Object, P = globalThis, $u = P.trustedTypes, se = $u ? $u.emptyScript : "", nu = P.reactiveElementPolyfillSupport, z = (t, u) => t, uu = { toAttribute(t, u) {
141
+ switch (u) {
142
+ case Boolean:
143
+ t = t ? se : null;
144
+ break;
145
+ case Object:
146
+ case Array:
147
+ t = t == null ? t : JSON.stringify(t);
148
+ }
149
+ return t;
150
+ }, fromAttribute(t, u) {
151
+ let e = t;
152
+ switch (u) {
153
+ case Boolean:
154
+ e = t !== null;
155
+ break;
156
+ case Number:
157
+ e = t === null ? null : Number(t);
158
+ break;
159
+ case Object:
160
+ case Array:
161
+ try {
162
+ e = JSON.parse(t);
163
+ } catch {
164
+ e = null;
100
165
  }
101
- /**
102
- * Checks if `value` is classified as a `Number` primitive or object.
103
- *
104
- * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
105
- * classified as numbers, use the `_.isFinite` method.
106
- *
107
- * @static
108
- * @memberOf _
109
- * @since 0.1.0
110
- * @category Lang
111
- * @param {*} value The value to check.
112
- * @returns {boolean} Returns `true` if `value` is a number, else `false`.
113
- * @example
114
- *
115
- * _.isNumber(3);
116
- * // => true
117
- *
118
- * _.isNumber(Number.MIN_VALUE);
119
- * // => true
120
- *
121
- * _.isNumber(Infinity);
122
- * // => true
123
- *
124
- * _.isNumber('3');
125
- * // => false
126
- */
127
- const output = function isNumber(value) {
128
- return typeof value == 'number' || isObjectLike(value) && objectToString.call(value) == numberTag;
129
- };
130
- return output;
131
- };
132
- const isNumber = buildIsNumber();
133
-
134
- const set = (obj, path, value) => {
135
- // Regex explained: https://regexr.com/58j0k
136
- const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
137
- pathArray?.reduce((acc, key, i) => {
138
- if (acc[key] === undefined) acc[key] = {};
139
- if (i === pathArray.length - 1) acc[key] = value;
140
- return acc[key];
141
- }, obj);
142
- };
143
-
144
- // MAKE SURE THESE MATCH VALUES IN types.EventKey
145
- /** Type check on whether target is a Lunchbox.EventKey */
146
- const isEventKey = target => {
147
- return ['onClick', 'onContextMenu', 'onDoubleClick', 'onPointerUp', 'onPointerDown', 'onPointerOver', 'onPointerOut', 'onPointerEnter', 'onPointerLeave', 'onPointerMove',
148
- // 'onPointerMissed',
149
- // 'onUpdate',
150
- 'onWheel'].includes(target);
151
- };
152
- const isLunchboxComponent = node => {
153
- return node?.$el && node?.$el?.hasOwnProperty?.('instance');
154
- };
155
- const isLunchboxDomComponent = node => {
156
- if (node?.metaType === 'domMeta') return true;
157
- return node?.props?.['data-lunchbox'];
158
- };
159
- const isLunchboxStandardNode = node => {
160
- return node?.metaType === 'standardMeta';
161
- };
162
- const isLunchboxRootNode = node => {
163
- return node.isLunchboxRootNode;
164
- };
165
-
166
- /** Create a new Lunchbox comment node. */
167
- function createCommentNode(options = {}) {
168
- const defaults = {
169
- text: options.text ?? ''
170
- };
171
- return new exports.MiniDom.RendererCommentNode({
172
- ...defaults,
173
- ...options,
174
- metaType: 'commentMeta'
175
- });
166
+ }
167
+ return e;
168
+ } }, pu = (t, u) => !Qu(t, u), bu = { attribute: !0, type: String, converter: uu, reflect: !1, hasChanged: pu };
169
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), P.litPropertyMetadata ?? (P.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
170
+ class k extends HTMLElement {
171
+ static addInitializer(u) {
172
+ this._$Ei(), (this.l ?? (this.l = [])).push(u);
173
+ }
174
+ static get observedAttributes() {
175
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
176
+ }
177
+ static createProperty(u, e = bu) {
178
+ if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(u, e), !e.noAccessor) {
179
+ const r = Symbol(), D = this.getPropertyDescriptor(u, r, e);
180
+ D !== void 0 && ue(this.prototype, u, D);
176
181
  }
177
- /** Create a new DOM node. */
178
- function createDomNode(options = {}) {
179
- const domElement = document.createElement(options.type ?? '');
180
- const defaults = {
181
- domElement
182
- };
183
- const node = new exports.MiniDom.RendererDomNode({
184
- ...defaults,
185
- ...options,
186
- metaType: 'domMeta'
187
- });
188
- return node;
182
+ }
183
+ static getPropertyDescriptor(u, e, r) {
184
+ const { get: D, set: s } = ee(this.prototype, u) ?? { get() {
185
+ return this[e];
186
+ }, set(i) {
187
+ this[e] = i;
188
+ } };
189
+ return { get() {
190
+ return D == null ? void 0 : D.call(this);
191
+ }, set(i) {
192
+ const a = D == null ? void 0 : D.call(this);
193
+ s.call(this, i), this.requestUpdate(u, a, r);
194
+ }, configurable: !0, enumerable: !0 };
195
+ }
196
+ static getPropertyOptions(u) {
197
+ return this.elementProperties.get(u) ?? bu;
198
+ }
199
+ static _$Ei() {
200
+ if (this.hasOwnProperty(z("elementProperties")))
201
+ return;
202
+ const u = De(this);
203
+ u.finalize(), u.l !== void 0 && (this.l = [...u.l]), this.elementProperties = new Map(u.elementProperties);
204
+ }
205
+ static finalize() {
206
+ if (this.hasOwnProperty(z("finalized")))
207
+ return;
208
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(z("properties"))) {
209
+ const e = this.properties, r = [...te(e), ...re(e)];
210
+ for (const D of r)
211
+ this.createProperty(D, e[D]);
189
212
  }
190
- /** Create a new Lunchbox text node. */
191
- function createTextNode(options = {}) {
192
- const defaults = {
193
- text: options.text ?? ''
194
- };
195
- return new exports.MiniDom.RendererTextNode({
196
- ...options,
197
- ...defaults,
198
- metaType: 'textMeta'
199
- });
200
- }
201
- /** Create a new Lunchbox standard node. */
202
- function createNode(options = {}, props = {}) {
203
- const defaults = {
204
- attached: options.attached ?? [],
205
- attachedArray: options.attachedArray ?? {},
206
- instance: options.instance ?? null
207
- };
208
- const node = new exports.MiniDom.RendererStandardNode({
209
- ...options,
210
- ...defaults,
211
- metaType: 'standardMeta'
212
- });
213
- if (node.type && !isLunchboxRootNode(node) && !node.instance) {
214
- node.instance = instantiateThreeObject({
215
- ...node,
216
- props: {
217
- ...node.props,
218
- ...props
219
- }
220
- });
221
- }
222
- return node;
213
+ const u = this[Symbol.metadata];
214
+ if (u !== null) {
215
+ const e = litPropertyMetadata.get(u);
216
+ if (e !== void 0)
217
+ for (const [r, D] of e)
218
+ this.elementProperties.set(r, D);
223
219
  }
224
-
225
- /** Add an event listener to the given node. Also creates the event teardown function and any necessary raycaster/interaction dictionary updates. */
226
- function addEventListener({
227
- node,
228
- key,
229
- interactables,
230
- value
231
- }) {
232
- // create new records for this key if needed
233
- if (!node.eventListeners[key]) {
234
- node.eventListeners[key] = [];
235
- }
236
- if (!node.eventListenerRemoveFunctions[key]) {
237
- node.eventListenerRemoveFunctions[key] = [];
238
- }
239
- // add event listener
240
- node.eventListeners[key].push(value);
241
- // if we need it, let's get/create the main raycaster
242
- if (interactionsRequiringRaycaster.includes(key)) {
243
- if (node.instance && !interactables.value.includes(node)) {
244
- // add to interactables
245
- interactables.value.push(node);
246
- node.eventListenerRemoveFunctions[key].push(() => {
247
- // remove from interactables
248
- const idx = interactables.value.indexOf(node);
249
- if (idx !== -1) {
250
- interactables.value.splice(idx, 1);
251
- }
252
- });
253
- }
254
- }
255
- return node;
220
+ this._$Eh = /* @__PURE__ */ new Map();
221
+ for (const [e, r] of this.elementProperties) {
222
+ const D = this._$Eu(e, r);
223
+ D !== void 0 && this._$Eh.set(D, e);
256
224
  }
257
- const interactionsRequiringRaycaster = ['onClick', 'onPointerUp', 'onPointerDown', 'onPointerOver', 'onPointerOut', 'onPointerEnter', 'onPointerLeave', 'onPointerMove'
258
- // 'onPointerMissed',
259
- ];
260
-
261
- const resizeCanvas = (camera, renderer, scene, width, height) => {
262
- // ignore if no element
263
- if (!renderer?.domElement || !scene || !camera) return;
264
- width = width ?? window.innerWidth;
265
- height = height ?? window.innerHeight;
266
- // update camera
267
- const aspect = width / height;
268
- if (camera.type?.toLowerCase() === 'perspectivecamera') {
269
- const perspectiveCamera = camera;
270
- perspectiveCamera.aspect = aspect;
271
- perspectiveCamera.updateProjectionMatrix();
272
- } else if (camera.type?.toLowerCase() === 'orthographiccamera') {
273
- // TODO: ortho camera update
274
- const orthoCamera = camera;
275
- const heightInTermsOfWidth = height / width;
276
- orthoCamera.top = heightInTermsOfWidth * 10;
277
- orthoCamera.bottom = -heightInTermsOfWidth * 10;
278
- orthoCamera.right = 10;
279
- orthoCamera.left = -10;
280
- orthoCamera.updateProjectionMatrix();
281
- } else ;
282
- // update canvas
283
- renderer.setSize(width, height);
284
- // render immediately so there's no flicker
285
- if (scene && camera) {
286
- renderer.render(vue.toRaw(scene), vue.toRaw(camera));
287
- }
288
- };
289
-
290
- const getInnerDimensions = node => {
291
- const computedStyle = getComputedStyle(node);
292
- const width = node.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
293
- const height = node.clientHeight - parseFloat(computedStyle.paddingTop) - parseFloat(computedStyle.paddingBottom);
294
- return {
295
- width,
296
- height
297
- };
298
- };
299
- const prepCanvas = (container, camera, renderer, scene, sizePolicy) => {
300
- const containerElement = container.value?.domElement;
301
- if (!containerElement) throw new Error('missing container');
302
- // save and size element
303
- const resizeCanvasByPolicy = () => {
304
- if (sizePolicy === 'container') {
305
- const dims = getInnerDimensions(containerElement);
306
- resizeCanvas(camera, renderer, scene, dims.width, dims.height);
307
- } else resizeCanvas(camera, renderer, scene);
308
- };
309
- resizeCanvasByPolicy();
310
- // attach listeners
311
- let observer = new ResizeObserver(() => {
312
- resizeCanvasByPolicy();
313
- });
314
- // window.addEventListener('resize', resizeCanvas)
315
- if (containerElement) {
316
- observer.observe(containerElement);
317
- }
318
- // cleanup
319
- return {
320
- dispose() {
321
- if (containerElement) {
322
- observer.unobserve(containerElement);
323
- }
324
- }
325
- };
326
- };
327
-
328
- const LunchboxScene = vue.defineComponent({
329
- name: 'LunchboxScene',
330
- setup(props, {
331
- slots
332
- }) {
333
- return () => vue.createVNode(vue.resolveComponent("scene"), null, {
334
- default: () => [slots.default?.()]
335
- });
336
- }
337
- });
338
-
339
- const LunchboxEventHandlers = vue.defineComponent({
340
- name: 'LunchboxEventHandlers',
341
- setup() {
342
- const interactables = useLunchboxInteractables();
343
- const globals = useGlobals();
344
- const mousePos = vue.ref({
345
- x: Infinity,
346
- y: Infinity
347
- });
348
- const inputActive = vue.ref(false);
349
- let currentIntersections = [];
350
- const raycaster = new THREE__namespace.Raycaster(new THREE__namespace.Vector3(), new THREE__namespace.Vector3(0, 0, -1));
351
- const fireEventsFromIntersections = ({
352
- element,
353
- eventKeys,
354
- intersection
355
- }) => {
356
- if (!element) return;
357
- eventKeys.forEach(eventKey => {
358
- if (element.eventListeners[eventKey]) {
359
- element.eventListeners[eventKey].forEach(cb => {
360
- cb({
361
- intersection
362
- });
363
- });
364
- }
365
- });
366
- };
367
- // add mouse listener to renderer DOM element when the element is ready
368
- onRendererReady(v => {
369
- if (!v?.domElement) return;
370
- // we have a DOM element, so let's add mouse listeners
371
- const {
372
- domElement
373
- } = v;
374
- const mouseMoveListener = evt => {
375
- const screenWidth = (domElement.width ?? 1) / globals.dpr;
376
- const screenHeight = (domElement.height ?? 1) / globals.dpr;
377
- mousePos.value.x = evt.offsetX / screenWidth * 2 - 1;
378
- mousePos.value.y = -(evt.offsetY / screenHeight) * 2 + 1;
379
- };
380
- const mouseDownListener = () => inputActive.value = true;
381
- const mouseUpListener = () => inputActive.value = false;
382
- // add mouse events
383
- domElement.addEventListener('pointermove', mouseMoveListener);
384
- domElement.addEventListener('pointerdown', mouseDownListener);
385
- domElement.addEventListener('pointerup', mouseUpListener);
386
- });
387
- const camera = useCamera();
388
- const update = () => {
389
- const c = camera.value;
390
- if (!c) return;
391
- // console.log(camera.value)
392
- raycaster.setFromCamera(mousePos.value, c);
393
- const intersections = raycaster.intersectObjects(interactables?.value.map(v => v.instance) ?? []);
394
- let leaveValues = [],
395
- entering = [],
396
- staying = [];
397
- // intersection arrays
398
- leaveValues = currentIntersections.map(v => v.intersection);
399
- // element arrays
400
- intersections?.forEach(intersection => {
401
- const currentIdx = currentIntersections.findIndex(v => v.intersection.object === intersection.object);
402
- if (currentIdx === -1) {
403
- const found = interactables?.value.find(v => v.instance?.uuid === intersection.object.uuid);
404
- if (found) {
405
- entering.push({
406
- element: found,
407
- intersection
408
- });
409
- }
410
- } else {
411
- const found = interactables?.value.find(v => v.instance?.uuid === intersection.object.uuid);
412
- if (found) {
413
- staying.push({
414
- element: found,
415
- intersection
416
- });
417
- }
418
- }
419
- // this is a current intersection, so it won't be in our `leave` array
420
- const leaveIdx = leaveValues.findIndex(v => v.object.uuid === intersection.object.uuid);
421
- if (leaveIdx !== -1) {
422
- leaveValues.splice(leaveIdx, 1);
423
- }
424
- });
425
- const leaving = leaveValues.map(intersection => {
426
- return {
427
- element: interactables?.value.find(interactable => interactable.instance?.uuid === intersection.object.uuid),
428
- intersection
429
- };
430
- });
431
- // new interactions
432
- entering.forEach(({
433
- element,
434
- intersection
435
- }) => {
436
- fireEventsFromIntersections({
437
- element,
438
- eventKeys: ['onPointerEnter'],
439
- intersection
440
- });
441
- });
442
- // unchanged interactions
443
- staying.forEach(({
444
- element,
445
- intersection
446
- }) => {
447
- const eventKeys = ['onPointerOver', 'onPointerMove'];
448
- fireEventsFromIntersections({
449
- element,
450
- eventKeys,
451
- intersection
452
- });
453
- });
454
- // exited interactions
455
- leaving.forEach(({
456
- element,
457
- intersection
458
- }) => {
459
- const eventKeys = ['onPointerLeave', 'onPointerOut'];
460
- fireEventsFromIntersections({
461
- element,
462
- eventKeys,
463
- intersection
464
- });
465
- });
466
- currentIntersections = [].concat(entering, staying);
467
- };
468
- // update function
469
- onBeforeRender(update);
470
- const teardown = () => offBeforeRender(update);
471
- vue.onBeforeUnmount(teardown);
472
- const clickEventKeys = ['onClick', 'onPointerDown', 'onPointerUp'];
473
- vue.watch(inputActive, isDown => {
474
- // run raycaster on click (necessary when `update` is not automatically called,
475
- // for example in `updateSource` functions)
476
- update();
477
- // meshes with multiple intersections receive multiple callbacks by default -
478
- // let's make it so they only receive one callback of each type per frame.
479
- // (ie usually when you click on a mesh, you expect only one click event to fire, even
480
- // if there are technically multiple intersections with that mesh)
481
- const uuidsInteractedWithThisFrame = [];
482
- currentIntersections.forEach(v => {
483
- clickEventKeys.forEach(key => {
484
- const id = v.element.uuid + key;
485
- if (isDown && (key === 'onClick' || key === 'onPointerDown')) {
486
- if (!uuidsInteractedWithThisFrame.includes(id)) {
487
- v.element.eventListeners[key]?.forEach(cb => cb({
488
- intersection: v.intersection
489
- }));
490
- uuidsInteractedWithThisFrame.push(id);
491
- }
492
- } else if (!isDown && key === 'onPointerUp') {
493
- if (!uuidsInteractedWithThisFrame.includes(id)) {
494
- v.element.eventListeners[key]?.forEach(cb => cb({
495
- intersection: v.intersection
496
- }));
497
- uuidsInteractedWithThisFrame.push(id);
498
- }
499
- }
500
- });
501
- });
502
- });
503
- // return arbitrary object to ensure instantiation
504
- // TODO: why can't we return a <raycaster/> here?
505
- return () => vue.createVNode(vue.resolveComponent("object3D"), null, null);
506
- }
507
- });
508
-
509
- /** fixed & fill styling for container */
510
- const fillStyle = position => {
511
- return {
512
- position,
513
- top: 0,
514
- right: 0,
515
- bottom: 0,
516
- left: 0,
517
- width: '100%',
518
- height: '100%',
519
- display: 'block'
520
- };
521
- };
522
- const LunchboxWrapper = vue.defineComponent({
523
- name: 'Lunchbox',
524
- props: {
525
- // These should match the Lunchbox.WrapperProps interface
526
- background: String,
527
- cameraArgs: Array,
528
- cameraLook: Array,
529
- cameraLookAt: Array,
530
- cameraPosition: Array,
531
- dpr: Number,
532
- ortho: Boolean,
533
- orthographic: Boolean,
534
- r3f: Boolean,
535
- rendererArguments: Object,
536
- rendererProperties: Object,
537
- sizePolicy: String,
538
- shadow: [Boolean, Object],
539
- transparent: Boolean,
540
- zoom: Number,
541
- updateSource: Object
542
- },
543
- setup(props, context) {
544
- const canvas = vue.ref();
545
- let dpr = props.dpr ?? -1;
546
- const container = vue.ref();
547
- const renderer = vue.ref();
548
- const camera = vue.ref();
549
- const scene = vue.ref();
550
- const globals = useGlobals();
551
- const updateGlobals = useUpdateGlobals();
552
- const app = useApp();
553
- const consolidatedCameraProperties = vue.reactive({});
554
- const startCallbacks = useStartCallbacks();
555
- // https://threejs.org/docs/index.html#manual/en/introduction/Color-management
556
- if (props.r3f && THREE__namespace?.ColorManagement) {
557
- THREE__namespace.ColorManagement.legacyMode = false;
558
- }
559
- const interactables = useLunchboxInteractables();
560
- // MOUNT
561
- // ====================
562
- vue.onMounted(async () => {
563
- // canvas needs to exist (or user needs to handle it on their own)
564
- if (!canvas.value && !context.slots?.renderer?.()?.length) throw new Error('missing canvas');
565
- // no camera provided, so let's create one
566
- if (!context.slots?.camera?.()?.length) {
567
- if (props.cameraPosition) {
568
- consolidatedCameraProperties.position = props.cameraPosition;
569
- }
570
- if (props.cameraLook || props.cameraLookAt) {
571
- consolidatedCameraProperties.lookAt = props.cameraLook || props.cameraLookAt;
572
- }
573
- if (props.zoom !== undefined) {
574
- consolidatedCameraProperties.zoom = props.zoom;
575
- }
576
- }
577
- // SCENE
578
- // ====================
579
- // set background color
580
- if (scene.value?.$el?.instance && props.background) {
581
- scene.value.$el.instance.background = new THREE__namespace.Color(props.background);
582
- }
583
- // MISC PROPERTIES
584
- // ====================
585
- if (dpr === -1) {
586
- dpr = window.devicePixelRatio;
587
- }
588
- updateGlobals?.({
589
- dpr
590
- });
591
- while (!renderer.value?.$el?.instance &&
592
- // TODO: remove `as any`
593
- !renderer.value?.component?.ctx.$el?.instance) {
594
- await new Promise(r => requestAnimationFrame(r));
595
- }
596
- while (!scene.value?.$el?.instance &&
597
- // TODO: remove `as any`
598
- !scene.value?.component?.ctx.$el?.instance) {
599
- await new Promise(r => requestAnimationFrame(r));
600
- }
601
- const normalizedRenderer = renderer.value?.$el?.instance ?? renderer.value?.component?.ctx.$el?.instance;
602
- normalizedRenderer.setPixelRatio(globals.dpr);
603
- const normalizedScene = scene.value?.$el?.instance ?? scene.value?.component?.ctx.$el?.instance;
604
- const normalizedCamera = camera.value?.$el?.instance ?? camera.value?.component?.ctx.$el?.instance;
605
- // TODO: update DPR on monitor switch
606
- // prep canvas (sizing, observe, unmount, etc)
607
- // (only run if no custom renderer)
608
- if (!context.slots?.renderer?.()?.length) {
609
- // TODO: use dispose
610
- prepCanvas(container, normalizedCamera, normalizedRenderer, normalizedScene, props.sizePolicy);
611
- if (props.r3f) {
612
- normalizedRenderer.outputEncoding = THREE__namespace.sRGBEncoding;
613
- normalizedRenderer.toneMapping = THREE__namespace.ACESFilmicToneMapping;
614
- }
615
- // update render sugar
616
- const sugar = {
617
- shadow: props.shadow
618
- };
619
- if (sugar?.shadow) {
620
- normalizedRenderer.shadowMap.enabled = true;
621
- if (typeof sugar.shadow === 'object') {
622
- normalizedRenderer.shadowMap.type = sugar.shadow.type;
623
- }
624
- }
625
- }
626
- // START
627
- // ====================
628
- if (!app) {
629
- throw new Error('error creating app');
630
- }
631
- // save renderer, scene, camera
632
- app.config.globalProperties.lunchbox.camera = normalizedCamera;
633
- app.config.globalProperties.lunchbox.renderer = normalizedRenderer;
634
- app.config.globalProperties.lunchbox.scene = normalizedScene;
635
- for (let startCallback of startCallbacks ?? []) {
636
- startCallback({
637
- app,
638
- camera: normalizedCamera,
639
- renderer: normalizedRenderer,
640
- scene: normalizedScene
641
- });
642
- }
643
- // KICK UPDATE
644
- // ====================
645
- update({
646
- app,
647
- camera: normalizedCamera,
648
- renderer: normalizedRenderer,
649
- scene: normalizedScene,
650
- updateSource: props.updateSource
651
- });
652
- });
653
- // UNMOUNT
654
- // ====================
655
- vue.onBeforeUnmount(() => {
656
- cancelUpdate();
657
- cancelUpdateSource();
658
- });
659
- // RENDER FUNCTION
660
- // ====================
661
- const containerFillStyle = props.sizePolicy === 'container' ? 'static' : 'absolute';
662
- const canvasFillStyle = props.sizePolicy === 'container' ? 'static' : 'fixed';
663
- // REACTIVE CUSTOM CAMERAS
664
- // ====================
665
- // find first camera with `type.name` property
666
- // (which indicates a Lunch.Node)
667
- const activeCamera = vue.computed(() => {
668
- const output = context.slots?.camera?.().find(c => c.type?.name);
669
- if (output) {
670
- return output;
671
- }
672
- return output;
673
- });
674
- // TODO: make custom cameras reactive
675
- vue.watch(activeCamera, async (newVal, oldVal) => {
676
- // console.log('got camera', newVal)
677
- if (newVal && newVal?.props?.key !== oldVal?.props?.key) {
678
- // TODO: remove cast
679
- camera.value = newVal;
680
- // TODO: why isn't this updating app camera?
681
- // const el = await waitFor(() => newVal.el)
682
- // console.log(el)
683
- // camera.value = el
684
- // console.log(newVal.uuid)
685
- // updateGlobals?.({ camera: el })
686
- }
687
- }, {
688
- immediate: true
689
- });
690
- // RENDER FUNCTION
691
- // ====================
692
- return () => vue.createVNode(vue.Fragment, null, [context.slots?.renderer?.()?.length ?
693
- // TODO: remove `as any` cast
694
- renderer.value = context.slots?.renderer?.()[0] : // ...otherwise, add canvas...
695
- vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
696
- "class": "lunchbox-container",
697
- "style": fillStyle(containerFillStyle),
698
- "ref": container,
699
- "data-lunchbox": "true"
700
- }, [vue.createVNode("canvas", {
701
- "ref": canvas,
702
- "class": "lunchbox-canvas",
703
- "style": fillStyle(canvasFillStyle),
704
- "data-lunchbox": "true"
705
- }, null)]), canvas.value?.domElement && vue.createVNode(vue.resolveComponent("webGLRenderer"), vue.mergeProps(props.rendererProperties ?? {}, {
706
- "ref": renderer,
707
- "args": [{
708
- alpha: props.transparent,
709
- antialias: true,
710
- canvas: canvas.value?.domElement,
711
- powerPreference: !!props.r3f ? 'high-performance' : 'default',
712
- ...(props.rendererArguments ?? {})
713
- }]
714
- }), null)]), context.slots?.scene?.()?.length ?
715
- // TODO: remove `as any` cast
716
- scene.value = context.slots?.scene?.()[0] : // ...otherwise, add default scene
717
- // TODO: why does this need to be a separate component? <scene> throws an error
718
- vue.createVNode(LunchboxScene, {
719
- "ref": scene
720
- }, {
721
- default: () => [context.slots?.default?.()]
722
- }), context.slots?.camera?.()?.length ?
723
- // TODO: remove `any` cast
724
- camera.value : props.ortho || props.orthographic ? vue.createVNode(vue.resolveComponent("orthographicCamera"), vue.mergeProps({
725
- "ref": camera,
726
- "args": props.cameraArgs ?? []
727
- }, consolidatedCameraProperties), null) : vue.createVNode(vue.resolveComponent("perspectiveCamera"), vue.mergeProps({
728
- "ref": camera,
729
- "args": props.cameraArgs ?? [props.r3f ? 75 : 45, 0.5625, 1, 1000]
730
- }, consolidatedCameraProperties), null), interactables?.value.length && vue.createVNode(LunchboxEventHandlers, null, null)]);
731
- }
732
- });
733
-
734
- // list of all components to register out of the box
735
- const autoGeneratedComponents = [
736
- // ThreeJS basics
737
- 'mesh', 'instancedMesh', 'scene', 'sprite', 'object3D',
738
- // geometry
739
- 'instancedBufferGeometry', 'bufferGeometry', 'boxBufferGeometry', 'circleBufferGeometry', 'coneBufferGeometry', 'cylinderBufferGeometry', 'dodecahedronBufferGeometry', 'extrudeBufferGeometry', 'icosahedronBufferGeometry', 'latheBufferGeometry', 'octahedronBufferGeometry', 'parametricBufferGeometry', 'planeBufferGeometry', 'polyhedronBufferGeometry', 'ringBufferGeometry', 'shapeBufferGeometry', 'sphereBufferGeometry', 'tetrahedronBufferGeometry', 'textBufferGeometry', 'torusBufferGeometry', 'torusKnotBufferGeometry', 'tubeBufferGeometry', 'wireframeGeometry', 'parametricGeometry', 'tetrahedronGeometry', 'octahedronGeometry', 'icosahedronGeometry', 'dodecahedronGeometry', 'polyhedronGeometry', 'tubeGeometry', 'torusKnotGeometry', 'torusGeometry',
740
- // textgeometry has been moved to /examples/jsm/geometries/TextGeometry
741
- // 'textGeometry',
742
- 'sphereGeometry', 'ringGeometry', 'planeGeometry', 'latheGeometry', 'shapeGeometry', 'extrudeGeometry', 'edgesGeometry', 'coneGeometry', 'cylinderGeometry', 'circleGeometry', 'boxGeometry',
743
- // materials
744
- 'material', 'shadowMaterial', 'spriteMaterial', 'rawShaderMaterial', 'shaderMaterial', 'pointsMaterial', 'meshPhysicalMaterial', 'meshStandardMaterial', 'meshPhongMaterial', 'meshToonMaterial', 'meshNormalMaterial', 'meshLambertMaterial', 'meshDepthMaterial', 'meshDistanceMaterial', 'meshBasicMaterial', 'meshMatcapMaterial', 'lineDashedMaterial', 'lineBasicMaterial',
745
- // lights
746
- 'light', 'spotLightShadow', 'spotLight', 'pointLight', 'rectAreaLight', 'hemisphereLight', 'directionalLightShadow', 'directionalLight', 'ambientLight', 'lightShadow', 'ambientLightProbe', 'hemisphereLightProbe', 'lightProbe',
747
- // textures
748
- 'texture', 'videoTexture', 'dataTexture', 'dataTexture3D', 'compressedTexture', 'cubeTexture', 'canvasTexture', 'depthTexture',
749
- // Texture loaders
750
- 'textureLoader',
751
- // misc
752
- 'group', 'catmullRomCurve3', 'points', 'raycaster',
753
- // helpers
754
- 'cameraHelper',
755
- // cameras
756
- 'camera', 'perspectiveCamera', 'orthographicCamera', 'cubeCamera', 'arrayCamera',
757
- // renderers
758
- 'webGLRenderer'
759
- /*
760
- // List copied from r3f:
761
- // https://github.com/pmndrs/react-three-fiber/blob/master/packages/fiber/src/three-types.ts
762
- // NOT IMPLEMENTED (can be added via Extend - docs.lunchboxjs.com/components/extend/):
763
- audioListener: AudioListenerProps
764
- positionalAudio: PositionalAudioProps
765
- lOD: LODProps
766
- skinnedMesh: SkinnedMeshProps
767
- skeleton: SkeletonProps
768
- bone: BoneProps
769
- lineSegments: LineSegmentsProps
770
- lineLoop: LineLoopProps
771
- // see `audio`
772
- // line: LineProps
773
- immediateRenderObject: ImmediateRenderObjectProps
774
- // primitive
775
- primitive: PrimitiveProps
776
- // helpers
777
- spotLightHelper: SpotLightHelperProps
778
- skeletonHelper: SkeletonHelperProps
779
- pointLightHelper: PointLightHelperProps
780
- hemisphereLightHelper: HemisphereLightHelperProps
781
- gridHelper: GridHelperProps
782
- polarGridHelper: PolarGridHelperProps
783
- directionalLightHelper: DirectionalLightHelperProps
784
- boxHelper: BoxHelperProps
785
- box3Helper: Box3HelperProps
786
- planeHelper: PlaneHelperProps
787
- arrowHelper: ArrowHelperProps
788
- axesHelper: AxesHelperProps
789
- // misc
790
- vector2: Vector2Props
791
- vector3: Vector3Props
792
- vector4: Vector4Props
793
- euler: EulerProps
794
- matrix3: Matrix3Props
795
- matrix4: Matrix4Props
796
- quaternion: QuaternionProps
797
- bufferAttribute: BufferAttributeProps
798
- instancedBufferAttribute: InstancedBufferAttributeProps
799
- color: ColorProps
800
- fog: FogProps
801
- fogExp2: FogExp2Props
802
- shape: ShapeProps
803
- */];
804
-
805
- const catalogue = {};
806
- // component creation utility
807
- const createComponent$1 = tag => vue.defineComponent({
808
- inheritAttrs: false,
809
- name: tag,
810
- setup(props, context) {
811
- return () => {
812
- return vue.h(tag, context.attrs, context.slots?.default?.() || []);
813
- };
814
- }
225
+ this.elementStyles = this.finalizeStyles(this.styles);
226
+ }
227
+ static finalizeStyles(u) {
228
+ const e = [];
229
+ if (Array.isArray(u)) {
230
+ const r = new Set(u.flat(1 / 0).reverse());
231
+ for (const D of r)
232
+ e.unshift(gu(D));
233
+ } else
234
+ u !== void 0 && e.push(gu(u));
235
+ return e;
236
+ }
237
+ static _$Eu(u, e) {
238
+ const r = e.attribute;
239
+ return r === !1 ? void 0 : typeof r == "string" ? r : typeof u == "string" ? u.toLowerCase() : void 0;
240
+ }
241
+ constructor() {
242
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
243
+ }
244
+ _$Ev() {
245
+ var u;
246
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (u = this.constructor.l) == null || u.forEach((e) => e(this));
247
+ }
248
+ addController(u) {
249
+ var e;
250
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(u), this.renderRoot !== void 0 && this.isConnected && ((e = u.hostConnected) == null || e.call(u));
251
+ }
252
+ removeController(u) {
253
+ var e;
254
+ (e = this._$EO) == null || e.delete(u);
255
+ }
256
+ _$E_() {
257
+ const u = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
258
+ for (const r of e.keys())
259
+ this.hasOwnProperty(r) && (u.set(r, this[r]), delete this[r]);
260
+ u.size > 0 && (this._$Ep = u);
261
+ }
262
+ createRenderRoot() {
263
+ const u = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
264
+ return Yu(u, this.constructor.elementStyles), u;
265
+ }
266
+ connectedCallback() {
267
+ var u;
268
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (u = this._$EO) == null || u.forEach((e) => {
269
+ var r;
270
+ return (r = e.hostConnected) == null ? void 0 : r.call(e);
815
271
  });
816
- // turn components into registered map
817
- const processed = autoGeneratedComponents.map(createComponent$1).reduce((acc, curr) => {
818
- acc[curr.name] = curr;
819
- return acc;
820
- }, {});
821
- const components = {
822
- ...processed,
823
- Lunchbox: LunchboxWrapper
824
- };
825
-
826
- const createComponent = tag => vue.defineComponent({
827
- inheritAttrs: false,
828
- name: tag,
829
- render() {
830
- return vue.h(tag, this.$attrs, this.$slots?.default?.() || []);
831
- }
272
+ }
273
+ enableUpdating(u) {
274
+ }
275
+ disconnectedCallback() {
276
+ var u;
277
+ (u = this._$EO) == null || u.forEach((e) => {
278
+ var r;
279
+ return (r = e.hostDisconnected) == null ? void 0 : r.call(e);
832
280
  });
833
- const extend = ({
834
- app,
835
- ...targets
836
- }) => {
837
- Object.keys(targets).forEach(key => {
838
- app.component(key, createComponent(key));
839
- catalogue[key] = targets[key];
840
- });
841
- };
842
-
843
- /** Process props into either themselves or the $attached value */
844
- function processProp({
845
- node,
846
- prop
847
- }) {
848
- // return $attachedArray value if needed
849
- if (typeof prop === 'string' && prop.startsWith('$attachedArray')) {
850
- return node.attachedArray[prop.replace('$attachedArray.', '')];
851
- }
852
- // return $attached value if needed
853
- if (typeof prop === 'string' && prop.startsWith('$attached')) {
854
- return node.attached[prop.replace('$attached.', '')];
855
- }
856
- // otherwise, return plain value
857
- return prop;
858
- }
859
- function processPropAsArray({
860
- node,
861
- prop
862
- }) {
863
- const isAttachedArray = typeof prop === 'string' && prop.startsWith('$attachedArray');
864
- const output = processProp({
865
- node,
866
- prop
867
- });
868
- return Array.isArray(output) && isAttachedArray ? output : [output];
869
- }
870
-
871
- function instantiateThreeObject(node) {
872
- if (!node.type) return null;
873
- // what class will we be instantiating?
874
- const uppercaseType = node.type[0].toUpperCase() + node.type.slice(1);
875
- const translatedType = uppercaseType.replace(/Lunchbox$/, '');
876
- const targetClass = catalogue[node.type] || THREE__namespace[uppercaseType] || catalogue[translatedType] || THREE__namespace[translatedType];
877
- if (!targetClass) throw `${uppercaseType} is not part of the THREE namespace! Did you forget to extend? import {extend} from 'lunchbox'; extend({app, YourComponent, ...})`;
878
- // what args have we been provided?
879
- const args = node.props.args ?? [];
880
- // replace $attached values with their instances
881
- // we need to guarantee everything comes back as an array so we can spread $attachedArrays,
882
- // so we'll use processPropAsArray
883
- const argsWrappedInArrays = args.map(arg => {
884
- return processPropAsArray({
885
- node,
886
- prop: arg
887
- });
888
- });
889
- let processedArgs = [];
890
- argsWrappedInArrays.forEach(arr => {
891
- processedArgs = processedArgs.concat(arr);
892
- });
893
- const instance = new targetClass(...processedArgs);
894
- return instance;
281
+ }
282
+ attributeChangedCallback(u, e, r) {
283
+ this._$AK(u, r);
284
+ }
285
+ _$EC(u, e) {
286
+ var s;
287
+ const r = this.constructor.elementProperties.get(u), D = this.constructor._$Eu(u, r);
288
+ if (D !== void 0 && r.reflect === !0) {
289
+ const i = (((s = r.converter) == null ? void 0 : s.toAttribute) !== void 0 ? r.converter : uu).toAttribute(e, r.type);
290
+ this._$Em = u, i == null ? this.removeAttribute(D) : this.setAttribute(D, i), this._$Em = null;
895
291
  }
896
-
897
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
898
- // require the crypto API and do not support built-in fallback to lower quality random number
899
- // generators (like Math.random()).
900
- var getRandomValues;
901
- var rnds8 = new Uint8Array(16);
902
- function rng() {
903
- // lazy load so that environments that need to polyfill have a chance to do so
904
- if (!getRandomValues) {
905
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
906
- // find the complete implementation of crypto (msCrypto) on IE11.
907
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
908
- if (!getRandomValues) {
909
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
910
- }
911
- }
912
- return getRandomValues(rnds8);
292
+ }
293
+ _$AK(u, e) {
294
+ var s;
295
+ const r = this.constructor, D = r._$Eh.get(u);
296
+ if (D !== void 0 && this._$Em !== D) {
297
+ const i = r.getPropertyOptions(D), a = typeof i.converter == "function" ? { fromAttribute: i.converter } : ((s = i.converter) == null ? void 0 : s.fromAttribute) !== void 0 ? i.converter : uu;
298
+ this._$Em = D, this[D] = a.fromAttribute(e, i.type), this._$Em = null;
913
299
  }
914
-
915
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
916
-
917
- function validate(uuid) {
918
- return typeof uuid === 'string' && REGEX.test(uuid);
300
+ }
301
+ requestUpdate(u, e, r) {
302
+ if (u !== void 0) {
303
+ if (r ?? (r = this.constructor.getPropertyOptions(u)), !(r.hasChanged ?? pu)(this[u], e))
304
+ return;
305
+ this.P(u, e, r);
919
306
  }
920
-
921
- /**
922
- * Convert array of 16 byte values to UUID string format of the form:
923
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
924
- */
925
-
926
- var byteToHex = [];
927
- for (var i = 0; i < 256; ++i) {
928
- byteToHex.push((i + 0x100).toString(16).substr(1));
307
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
308
+ }
309
+ P(u, e, r) {
310
+ this._$AL.has(u) || this._$AL.set(u, e), r.reflect === !0 && this._$Em !== u && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(u);
311
+ }
312
+ async _$ET() {
313
+ this.isUpdatePending = !0;
314
+ try {
315
+ await this._$ES;
316
+ } catch (e) {
317
+ Promise.reject(e);
929
318
  }
930
- function stringify(arr) {
931
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
932
- // Note: Be careful editing this code! It's been tuned for performance
933
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
934
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
935
- // of the following:
936
- // - One or more input array values don't map to a hex octet (leading to
937
- // "undefined" in the uuid)
938
- // - Invalid input values for the RFC `version` or `variant` fields
939
-
940
- if (!validate(uuid)) {
941
- throw TypeError('Stringified UUID is invalid');
319
+ const u = this.scheduleUpdate();
320
+ return u != null && await u, !this.isUpdatePending;
321
+ }
322
+ scheduleUpdate() {
323
+ return this.performUpdate();
324
+ }
325
+ performUpdate() {
326
+ var r;
327
+ if (!this.isUpdatePending)
328
+ return;
329
+ if (!this.hasUpdated) {
330
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
331
+ for (const [s, i] of this._$Ep)
332
+ this[s] = i;
333
+ this._$Ep = void 0;
942
334
  }
943
- return uuid;
335
+ const D = this.constructor.elementProperties;
336
+ if (D.size > 0)
337
+ for (const [s, i] of D)
338
+ i.wrapped !== !0 || this._$AL.has(s) || this[s] === void 0 || this.P(s, this[s], i);
944
339
  }
945
-
946
- function v4(options, buf, offset) {
947
- options = options || {};
948
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
949
-
950
- rnds[6] = rnds[6] & 0x0f | 0x40;
951
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
952
-
953
- if (buf) {
954
- offset = offset || 0;
955
- for (var i = 0; i < 16; ++i) {
956
- buf[offset + i] = rnds[i];
957
- }
958
- return buf;
959
- }
960
- return stringify(rnds);
340
+ let u = !1;
341
+ const e = this._$AL;
342
+ try {
343
+ u = this.shouldUpdate(e), u ? (this.willUpdate(e), (r = this._$EO) == null || r.forEach((D) => {
344
+ var s;
345
+ return (s = D.hostUpdate) == null ? void 0 : s.call(D);
346
+ }), this.update(e)) : this._$EU();
347
+ } catch (D) {
348
+ throw u = !1, this._$EU(), D;
961
349
  }
962
-
963
- // MiniDom recreates DOM node properties and methods.
964
- // Since Vue 3 is a DOM-first framework, many of its nodeOps depend on
965
- // properties and methods the DOM naturally contains. MiniDom recreates
966
- // those properties (as well as a few from the tree-model npm package)
967
- // to make a DOM-like but otherwise agnostic hierarchy structure.
968
- exports.MiniDom = void 0;
969
- (function (MiniDom) {
970
- class BaseNode {
971
- constructor(options = {}, parent) {
972
- this.parentNode = options?.parentNode ?? parent ?? null;
973
- this.minidomType = 'MinidomBaseNode';
974
- this.uuid = options?.uuid ?? v4();
975
- // allNodes.push(this)
976
- }
977
-
978
- uuid;
979
- // DOM FEATURES
980
- // ====================
981
- parentNode;
982
- get nextSibling() {
983
- if (!this.parentNode) return null;
984
- const idx = this.parentNode.children.findIndex(n => n.uuid === this.uuid);
985
- // return next sibling if we're present and not the last child of the parent
986
- if (idx !== -1 && idx < this.parentNode.children.length - 1) {
987
- return this.parentNode.children[idx + 1];
988
- }
989
- return null;
990
- }
991
- insertBefore(child, anchor) {
992
- child.removeAsChildFromAnyParents();
993
- child.parentNode = this;
994
- const anchorIdx = this.children.findIndex(n => n.uuid === anchor?.uuid);
995
- if (anchorIdx !== -1) {
996
- this.children.splice(anchorIdx, 0, child);
997
- } else {
998
- this.children.push(child);
999
- }
1000
- }
1001
- removeChild(child) {
1002
- const idx = this.children.findIndex(n => n?.uuid === child?.uuid);
1003
- if (idx !== -1) {
1004
- this.children.splice(idx, 1);
1005
- }
1006
- }
1007
- // TREE FEATURES
1008
- // ====================
1009
- children = [];
1010
- addChild(child) {
1011
- if (child) {
1012
- // remove child from any other parents
1013
- child.removeAsChildFromAnyParents();
1014
- // add to this node
1015
- child.parentNode = this;
1016
- this.insertBefore(child, null);
1017
- }
1018
- return this;
1019
- }
1020
- /** Get the array of Nodes representing the path from the root to this Node (inclusive). */
1021
- getPath() {
1022
- const output = [];
1023
- let current = this;
1024
- while (current) {
1025
- output.unshift(current);
1026
- current = current.parentNode;
1027
- }
1028
- return output;
1029
- }
1030
- /** Drop this node. Removes parent's knowledge of this node
1031
- * and resets this node's internal parent. */
1032
- drop() {
1033
- // remove as child
1034
- this.removeAsChildFromAnyParents();
1035
- // remove parent
1036
- this.parentNode = null;
1037
- }
1038
- /** Walk over the entire subtree. Return falsey value in callback to end early. */
1039
- // TODO: depth-first vs breadth-first
1040
- walk(callback) {
1041
- const queue = [this, ...this.children];
1042
- const traversed = [];
1043
- let canContinue = true;
1044
- while (queue.length && canContinue) {
1045
- const current = queue.shift();
1046
- if (current) {
1047
- if (traversed.includes(current)) continue;
1048
- traversed.push(current);
1049
- queue.push(...current.children.filter(child => !traversed.includes(child)));
1050
- canContinue = callback(current);
1051
- } else {
1052
- canContinue = false;
1053
- }
350
+ u && this._$AE(e);
351
+ }
352
+ willUpdate(u) {
353
+ }
354
+ _$AE(u) {
355
+ var e;
356
+ (e = this._$EO) == null || e.forEach((r) => {
357
+ var D;
358
+ return (D = r.hostUpdated) == null ? void 0 : D.call(r);
359
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(u)), this.updated(u);
360
+ }
361
+ _$EU() {
362
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
363
+ }
364
+ get updateComplete() {
365
+ return this.getUpdateComplete();
366
+ }
367
+ getUpdateComplete() {
368
+ return this._$ES;
369
+ }
370
+ shouldUpdate(u) {
371
+ return !0;
372
+ }
373
+ update(u) {
374
+ this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
375
+ }
376
+ updated(u) {
377
+ }
378
+ firstUpdated(u) {
379
+ }
380
+ }
381
+ k.elementStyles = [], k.shadowRootOptions = { mode: "open" }, k[z("elementProperties")] = /* @__PURE__ */ new Map(), k[z("finalized")] = /* @__PURE__ */ new Map(), nu == null || nu({ ReactiveElement: k }), (P.reactiveElementVersions ?? (P.reactiveElementVersions = [])).push("2.0.4");
382
+ /**
383
+ * @license
384
+ * Copyright 2017 Google LLC
385
+ * SPDX-License-Identifier: BSD-3-Clause
386
+ */
387
+ const V = globalThis, eu = V.trustedTypes, _u = eu ? eu.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, ku = "$lit$", S = `lit$${Math.random().toFixed(9).slice(2)}$`, Hu = "?" + S, ie = `<${Hu}>`, L = document, q = () => L.createComment(""), J = (t) => t === null || typeof t != "object" && typeof t != "function", Ru = Array.isArray, ne = (t) => Ru(t) || typeof (t == null ? void 0 : t[Symbol.iterator]) == "function", ou = `[
388
+ \f\r]`, j = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, vu = /-->/g, wu = />/g, N = RegExp(`>|${ou}(?:([^\\s"'>=/]+)(${ou}*=${ou}*(?:[^
389
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Su = /'/g, Pu = /"/g, Iu = /^(?:script|style|textarea|title)$/i, oe = (t) => (u, ...e) => ({ _$litType$: t, strings: u, values: e }), Uu = oe(1), R = Symbol.for("lit-noChange"), B = Symbol.for("lit-nothing"), xu = /* @__PURE__ */ new WeakMap(), O = L.createTreeWalker(L, 129);
390
+ function ju(t, u) {
391
+ if (!Array.isArray(t) || !t.hasOwnProperty("raw"))
392
+ throw Error("invalid template strings array");
393
+ return _u !== void 0 ? _u.createHTML(u) : u;
394
+ }
395
+ const ae = (t, u) => {
396
+ const e = t.length - 1, r = [];
397
+ let D, s = u === 2 ? "<svg>" : "", i = j;
398
+ for (let a = 0; a < e; a++) {
399
+ const o = t[a];
400
+ let F, d, l = -1, $ = 0;
401
+ for (; $ < o.length && (i.lastIndex = $, d = i.exec(o), d !== null); )
402
+ $ = i.lastIndex, i === j ? d[1] === "!--" ? i = vu : d[1] !== void 0 ? i = wu : d[2] !== void 0 ? (Iu.test(d[2]) && (D = RegExp("</" + d[2], "g")), i = N) : d[3] !== void 0 && (i = N) : i === N ? d[0] === ">" ? (i = D ?? j, l = -1) : d[1] === void 0 ? l = -2 : (l = i.lastIndex - d[2].length, F = d[1], i = d[3] === void 0 ? N : d[3] === '"' ? Pu : Su) : i === Pu || i === Su ? i = N : i === vu || i === wu ? i = j : (i = N, D = void 0);
403
+ const w = i === N && t[a + 1].startsWith("/>") ? " " : "";
404
+ s += i === j ? o + ie : l >= 0 ? (r.push(F), o.slice(0, l) + ku + o.slice(l) + S + w) : o + S + (l === -2 ? a : w);
405
+ }
406
+ return [ju(t, s + (t[e] || "<?>") + (u === 2 ? "</svg>" : "")), r];
407
+ };
408
+ class Z {
409
+ constructor({ strings: u, _$litType$: e }, r) {
410
+ let D;
411
+ this.parts = [];
412
+ let s = 0, i = 0;
413
+ const a = u.length - 1, o = this.parts, [F, d] = ae(u, e);
414
+ if (this.el = Z.createElement(F, r), O.currentNode = this.el.content, e === 2) {
415
+ const l = this.el.content.firstChild;
416
+ l.replaceWith(...l.childNodes);
417
+ }
418
+ for (; (D = O.nextNode()) !== null && o.length < a; ) {
419
+ if (D.nodeType === 1) {
420
+ if (D.hasAttributes())
421
+ for (const l of D.getAttributeNames())
422
+ if (l.endsWith(ku)) {
423
+ const $ = d[i++], w = D.getAttribute(l).split(S), X = /([.?@])?(.*)/.exec($);
424
+ o.push({ type: 1, index: s, name: X[2], strings: w, ctor: X[1] === "." ? Ae : X[1] === "?" ? Ce : X[1] === "@" ? he : Du }), D.removeAttribute(l);
425
+ } else
426
+ l.startsWith(S) && (o.push({ type: 6, index: s }), D.removeAttribute(l));
427
+ if (Iu.test(D.tagName)) {
428
+ const l = D.textContent.split(S), $ = l.length - 1;
429
+ if ($ > 0) {
430
+ D.textContent = eu ? eu.emptyScript : "";
431
+ for (let w = 0; w < $; w++)
432
+ D.append(l[w], q()), O.nextNode(), o.push({ type: 2, index: ++s });
433
+ D.append(l[$], q());
1054
434
  }
1055
435
  }
1056
- // INTERNAL FEATURES
1057
- // ====================
1058
- minidomType;
1059
- removeAsChildFromAnyParents() {
1060
- this.parentNode?.removeChild(this);
1061
- }
1062
- }
1063
- MiniDom.BaseNode = BaseNode;
1064
- class RendererBaseNode extends MiniDom.BaseNode {
1065
- constructor(options = {}, parent) {
1066
- super(options, parent);
1067
- this.minidomType = 'RendererNode';
1068
- this.eventListeners = {};
1069
- this.eventListenerRemoveFunctions = {};
1070
- this.name = options.name ?? '';
1071
- this.metaType = options.metaType ?? 'standardMeta';
1072
- this.props = options.props ?? [];
1073
- this.type = options.type ?? '';
1074
- }
1075
- eventListeners;
1076
- eventListenerRemoveFunctions;
1077
- name;
1078
- metaType;
1079
- props;
1080
- type;
1081
- drop() {
1082
- super.drop();
1083
- // handle remove functions
1084
- Object.keys(this.eventListenerRemoveFunctions).forEach(key => {
1085
- this.eventListenerRemoveFunctions[key].forEach(func => func());
1086
- });
1087
- }
1088
- }
1089
- MiniDom.RendererBaseNode = RendererBaseNode;
1090
- // ====================
1091
- // SPECIFIC RENDERER NODES BELOW
1092
- // ====================
1093
- class RendererRootNode extends MiniDom.RendererBaseNode {
1094
- constructor(options = {}, parent) {
1095
- super(options, parent);
1096
- this.domElement = options.domElement ?? document.createElement('div');
1097
- }
1098
- domElement;
1099
- isLunchboxRootNode = true;
1100
- }
1101
- MiniDom.RendererRootNode = RendererRootNode;
1102
- class RendererCommentNode extends MiniDom.RendererBaseNode {
1103
- constructor(options = {}, parent) {
1104
- super(options, parent);
1105
- this.text = options.text ?? '';
1106
- }
1107
- text;
1108
- }
1109
- MiniDom.RendererCommentNode = RendererCommentNode;
1110
- class RendererDomNode extends MiniDom.RendererBaseNode {
1111
- constructor(options = {}, parent) {
1112
- super(options, parent);
1113
- this.domElement = options.domElement ?? document.createElement('div');
1114
- }
1115
- domElement;
1116
- }
1117
- MiniDom.RendererDomNode = RendererDomNode;
1118
- class RendererTextNode extends MiniDom.RendererBaseNode {
1119
- constructor(options = {}, parent) {
1120
- super(options, parent);
1121
- this.text = options.text ?? '';
436
+ } else if (D.nodeType === 8)
437
+ if (D.data === Hu)
438
+ o.push({ type: 2, index: s });
439
+ else {
440
+ let l = -1;
441
+ for (; (l = D.data.indexOf(S, l + 1)) !== -1; )
442
+ o.push({ type: 7, index: s }), l += S.length - 1;
1122
443
  }
1123
- text;
1124
- }
1125
- MiniDom.RendererTextNode = RendererTextNode;
1126
- class RendererStandardNode extends MiniDom.RendererBaseNode {
1127
- constructor(options = {}, parent) {
1128
- super(options, parent);
1129
- this.attached = options.attached ?? [];
1130
- this.attachedArray = options.attachedArray ?? {};
1131
- this.instance = options.instance ?? null;
1132
- }
1133
- attached;
1134
- attachedArray;
1135
- instance;
1136
- }
1137
- MiniDom.RendererStandardNode = RendererStandardNode;
1138
- })(exports.MiniDom || (exports.MiniDom = {}));
1139
- function isMinidomNode(item) {
1140
- return item?.minidomType === 'RendererNode';
444
+ s++;
1141
445
  }
1142
-
1143
- // These keys originally used Symbols per Vue instructions,
1144
- // but differing dev/build values made dev difficult.
1145
- // These strings have some risk of namespace collision,
1146
- // but that's a low enough risk that they're worth hardcoding
1147
- // as strings, in my opinion.
1148
- const globalsInjectionKey = 'lunchbox-globals'; // Symbol()
1149
- const updateGlobalsInjectionKey = 'lunchbox-updateGlobals'; // Symbol()
1150
- const setCustomRenderKey = 'lunchbox-setCustomRender'; // Symbol()
1151
- const clearCustomRenderKey = 'lunchbox-clearCustomRender'; //Symbol()
1152
- const beforeRenderKey = 'lunchbox-beforeRender'; // Symbol()
1153
- const onBeforeRenderKey = 'lunchbox-onBeforeRender'; //Symbol()
1154
- const offBeforeRenderKey = 'lunchbox-offBeforeRender'; // Symbol()
1155
- const afterRenderKey = 'lunchbox-afterRender'; // Symbol()
1156
- const onAfterRenderKey = 'lunchbox-onAfterRender'; // Symbol()
1157
- const offAfterRenderKey = 'lunchbox-offAfterRender'; // Symbol()
1158
- const frameIdKey = 'lunchbox-frameId'; // Symbol()
1159
- const watchStopHandleKey = 'lunchbox-watchStopHandle'; // Symbol()
1160
- const appRootNodeKey = 'lunchbox-appRootNode'; // Symbol()
1161
- const appKey = 'lunchbox-appKey'; // Symbol()
1162
- const appRenderersKey = 'lunchbox-renderer'; //Symbol()
1163
- const appSceneKey = 'lunchbox-scene'; // Symbol()
1164
- const appCameraKey = 'lunchbox-camera'; //Symbol()
1165
- const lunchboxInteractables = 'lunchbox-interactables'; // Symbol()
1166
- const startCallbackKey = 'lunchbox-startCallback'; // Symbol()
1167
-
1168
- const requestUpdate = opts => {
1169
- if (typeof opts.app.config.globalProperties.lunchbox.frameId === 'number') {
1170
- cancelAnimationFrame(opts.app.config.globalProperties.lunchbox.frameId);
1171
- }
1172
- opts.app.config.globalProperties.lunchbox.frameId = requestAnimationFrame(() => update({
1173
- app: opts.app,
1174
- renderer: opts.renderer,
1175
- scene: opts.scene,
1176
- camera: opts.camera,
1177
- updateSource: opts.updateSource
1178
- }));
1179
- };
1180
- const update = opts => {
1181
- if (opts.updateSource) {
1182
- if (!opts.app.config.globalProperties.lunchbox.watchStopHandle) {
1183
- // request next frame only when state changes
1184
- opts.app.config.globalProperties.lunchbox.watchStopHandle = vue.watch(opts.updateSource, () => {
1185
- requestUpdate(opts);
1186
- }, {
1187
- deep: true
1188
- });
1189
- }
1190
- } else {
1191
- // request next frame on a continuous loop
1192
- requestUpdate(opts);
1193
- }
1194
- // prep options
1195
- const {
1196
- app,
1197
- renderer,
1198
- scene
1199
- } = opts;
1200
- // BEFORE RENDER
1201
- app.config.globalProperties.lunchbox.beforeRender.forEach(cb => {
1202
- cb?.(opts);
1203
- });
1204
- // RENDER
1205
- if (renderer && scene && opts.app.config.globalProperties.lunchbox.camera) {
1206
- if (app.customRender) {
1207
- app.customRender(opts);
1208
- } else {
1209
- renderer.render(vue.toRaw(scene), opts.app.config.globalProperties.lunchbox.camera
1210
- // toRaw(camera)
1211
- );
1212
- }
446
+ }
447
+ static createElement(u, e) {
448
+ const r = L.createElement("template");
449
+ return r.innerHTML = u, r;
450
+ }
451
+ }
452
+ function I(t, u, e = t, r) {
453
+ var i, a;
454
+ if (u === R)
455
+ return u;
456
+ let D = r !== void 0 ? (i = e._$Co) == null ? void 0 : i[r] : e._$Cl;
457
+ const s = J(u) ? void 0 : u._$litDirective$;
458
+ return (D == null ? void 0 : D.constructor) !== s && ((a = D == null ? void 0 : D._$AO) == null || a.call(D, !1), s === void 0 ? D = void 0 : (D = new s(t), D._$AT(t, e, r)), r !== void 0 ? (e._$Co ?? (e._$Co = []))[r] = D : e._$Cl = D), D !== void 0 && (u = I(t, D._$AS(t, u.values), D, r)), u;
459
+ }
460
+ class ce {
461
+ constructor(u, e) {
462
+ this._$AV = [], this._$AN = void 0, this._$AD = u, this._$AM = e;
463
+ }
464
+ get parentNode() {
465
+ return this._$AM.parentNode;
466
+ }
467
+ get _$AU() {
468
+ return this._$AM._$AU;
469
+ }
470
+ u(u) {
471
+ const { el: { content: e }, parts: r } = this._$AD, D = ((u == null ? void 0 : u.creationScope) ?? L).importNode(e, !0);
472
+ O.currentNode = D;
473
+ let s = O.nextNode(), i = 0, a = 0, o = r[0];
474
+ for (; o !== void 0; ) {
475
+ if (i === o.index) {
476
+ let F;
477
+ o.type === 2 ? F = new K(s, s.nextSibling, this, u) : o.type === 1 ? F = new o.ctor(s, o.name, o.strings, this, u) : o.type === 6 && (F = new Ee(s, this, u)), this._$AV.push(F), o = r[++a];
1213
478
  }
1214
- // AFTER RENDER
1215
- app.config.globalProperties.lunchbox.afterRender.forEach(cb => {
1216
- cb?.(opts);
1217
- });
1218
- };
1219
- // before render
1220
- // ====================
1221
- /** Obtain callback methods for `onBeforeRender` and `offBeforeRender`. Usually used internally by Lunchbox. */
1222
- const useBeforeRender = () => {
1223
- return {
1224
- onBeforeRender: vue.inject(onBeforeRenderKey),
1225
- offBeforeRender: vue.inject(offBeforeRenderKey)
1226
- };
1227
- };
1228
- /** Run a function before every render.
1229
- *
1230
- * Note that if `updateSource` is set in the Lunchbox wrapper component, this will **only** run
1231
- * before a render triggered by that `updateSource`. Normally, the function should run every frame.
1232
- */
1233
- const onBeforeRender = (cb, index = Infinity) => {
1234
- useBeforeRender().onBeforeRender?.(cb, index);
1235
- };
1236
- /** Remove a function from the `beforeRender` callback list. Useful for tearing down functions added
1237
- * by `onBeforeRender`.
1238
- */
1239
- const offBeforeRender = cb => {
1240
- useBeforeRender().offBeforeRender?.(cb);
1241
- };
1242
- // after render
1243
- // ====================
1244
- /** Obtain callback methods for `onAfterRender` and `offAfterRender`. Usually used internally by Lunchbox. */
1245
- const useAfterRender = () => {
1246
- return {
1247
- onAfterRender: vue.inject(onBeforeRenderKey),
1248
- offAfterRender: vue.inject(offBeforeRenderKey)
1249
- };
1250
- };
1251
- /** Run a function after every render.
1252
- *
1253
- * Note that if `updateSource` is set in the Lunchbox wrapper component, this will **only** run
1254
- * after a render triggered by that `updateSource`. Normally, the function should run every frame.
1255
- */
1256
- const onAfterRender = (cb, index = Infinity) => {
1257
- useBeforeRender().onBeforeRender?.(cb, index);
1258
- };
1259
- /** Remove a function from the `afterRender` callback list. Useful for tearing down functions added
1260
- * by `onAfterRender`.
1261
- */
1262
- const offAfterRender = cb => {
1263
- useBeforeRender().offBeforeRender?.(cb);
1264
- };
1265
- /** Obtain a function used to cancel the current update frame. Use `cancelUpdate` if you wish
1266
- * to immediately invoke the cancellation function. Usually used internally by Lunchbox.
1267
- */
1268
- const useCancelUpdate = () => {
1269
- const frameId = vue.inject(frameIdKey);
1270
- return () => {
1271
- if (frameId !== undefined) cancelAnimationFrame(frameId);
1272
- };
1273
- };
1274
- /** Cancel the current update frame. Usually used internally by Lunchbox. */
1275
- const cancelUpdate = () => {
1276
- useCancelUpdate()?.();
1277
- };
1278
- /** Obtain a function used to cancel an update source. Use `cancelUpdateSource` if you wish to
1279
- * immediately invoke the cancellation function. Usually used internally by Lunchbox.
1280
- */
1281
- const useCancelUpdateSource = () => {
1282
- const cancel = vue.inject(watchStopHandleKey);
1283
- return () => cancel?.();
1284
- };
1285
- /** Cancel an update source. Usually used internally by Lunchbox. */
1286
- const cancelUpdateSource = () => {
1287
- useCancelUpdateSource()?.();
479
+ i !== (o == null ? void 0 : o.index) && (s = O.nextNode(), i++);
480
+ }
481
+ return O.currentNode = L, D;
482
+ }
483
+ p(u) {
484
+ let e = 0;
485
+ for (const r of this._$AV)
486
+ r !== void 0 && (r.strings !== void 0 ? (r._$AI(u, r, e), e += r.strings.length - 2) : r._$AI(u[e])), e++;
487
+ }
488
+ }
489
+ class K {
490
+ get _$AU() {
491
+ var u;
492
+ return ((u = this._$AM) == null ? void 0 : u._$AU) ?? this._$Cv;
493
+ }
494
+ constructor(u, e, r, D) {
495
+ this.type = 2, this._$AH = B, this._$AN = void 0, this._$AA = u, this._$AB = e, this._$AM = r, this.options = D, this._$Cv = (D == null ? void 0 : D.isConnected) ?? !0;
496
+ }
497
+ get parentNode() {
498
+ let u = this._$AA.parentNode;
499
+ const e = this._$AM;
500
+ return e !== void 0 && (u == null ? void 0 : u.nodeType) === 11 && (u = e.parentNode), u;
501
+ }
502
+ get startNode() {
503
+ return this._$AA;
504
+ }
505
+ get endNode() {
506
+ return this._$AB;
507
+ }
508
+ _$AI(u, e = this) {
509
+ u = I(this, u, e), J(u) ? u === B || u == null || u === "" ? (this._$AH !== B && this._$AR(), this._$AH = B) : u !== this._$AH && u !== R && this._(u) : u._$litType$ !== void 0 ? this.$(u) : u.nodeType !== void 0 ? this.T(u) : ne(u) ? this.k(u) : this._(u);
510
+ }
511
+ S(u) {
512
+ return this._$AA.parentNode.insertBefore(u, this._$AB);
513
+ }
514
+ T(u) {
515
+ this._$AH !== u && (this._$AR(), this._$AH = this.S(u));
516
+ }
517
+ _(u) {
518
+ this._$AH !== B && J(this._$AH) ? this._$AA.nextSibling.data = u : this.T(L.createTextNode(u)), this._$AH = u;
519
+ }
520
+ $(u) {
521
+ var s;
522
+ const { values: e, _$litType$: r } = u, D = typeof r == "number" ? this._$AC(u) : (r.el === void 0 && (r.el = Z.createElement(ju(r.h, r.h[0]), this.options)), r);
523
+ if (((s = this._$AH) == null ? void 0 : s._$AD) === D)
524
+ this._$AH.p(e);
525
+ else {
526
+ const i = new ce(D, this), a = i.u(this.options);
527
+ i.p(e), this.T(a), this._$AH = i;
528
+ }
529
+ }
530
+ _$AC(u) {
531
+ let e = xu.get(u.strings);
532
+ return e === void 0 && xu.set(u.strings, e = new Z(u)), e;
533
+ }
534
+ k(u) {
535
+ Ru(this._$AH) || (this._$AH = [], this._$AR());
536
+ const e = this._$AH;
537
+ let r, D = 0;
538
+ for (const s of u)
539
+ D === e.length ? e.push(r = new K(this.S(q()), this.S(q()), this, this.options)) : r = e[D], r._$AI(s), D++;
540
+ D < e.length && (this._$AR(r && r._$AB.nextSibling, D), e.length = D);
541
+ }
542
+ _$AR(u = this._$AA.nextSibling, e) {
543
+ var r;
544
+ for ((r = this._$AP) == null ? void 0 : r.call(this, !1, !0, e); u && u !== this._$AB; ) {
545
+ const D = u.nextSibling;
546
+ u.remove(), u = D;
547
+ }
548
+ }
549
+ setConnected(u) {
550
+ var e;
551
+ this._$AM === void 0 && (this._$Cv = u, (e = this._$AP) == null || e.call(this, u));
552
+ }
553
+ }
554
+ class Du {
555
+ get tagName() {
556
+ return this.element.tagName;
557
+ }
558
+ get _$AU() {
559
+ return this._$AM._$AU;
560
+ }
561
+ constructor(u, e, r, D, s) {
562
+ this.type = 1, this._$AH = B, this._$AN = void 0, this.element = u, this.name = e, this._$AM = D, this.options = s, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = B;
563
+ }
564
+ _$AI(u, e = this, r, D) {
565
+ const s = this.strings;
566
+ let i = !1;
567
+ if (s === void 0)
568
+ u = I(this, u, e, 0), i = !J(u) || u !== this._$AH && u !== R, i && (this._$AH = u);
569
+ else {
570
+ const a = u;
571
+ let o, F;
572
+ for (u = s[0], o = 0; o < s.length - 1; o++)
573
+ F = I(this, a[r + o], e, o), F === R && (F = this._$AH[o]), i || (i = !J(F) || F !== this._$AH[o]), F === B ? u = B : u !== B && (u += (F ?? "") + s[o + 1]), this._$AH[o] = F;
574
+ }
575
+ i && !D && this.j(u);
576
+ }
577
+ j(u) {
578
+ u === B ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, u ?? "");
579
+ }
580
+ }
581
+ class Ae extends Du {
582
+ constructor() {
583
+ super(...arguments), this.type = 3;
584
+ }
585
+ j(u) {
586
+ this.element[this.name] = u === B ? void 0 : u;
587
+ }
588
+ }
589
+ class Ce extends Du {
590
+ constructor() {
591
+ super(...arguments), this.type = 4;
592
+ }
593
+ j(u) {
594
+ this.element.toggleAttribute(this.name, !!u && u !== B);
595
+ }
596
+ }
597
+ class he extends Du {
598
+ constructor(u, e, r, D, s) {
599
+ super(u, e, r, D, s), this.type = 5;
600
+ }
601
+ _$AI(u, e = this) {
602
+ if ((u = I(this, u, e, 0) ?? B) === R)
603
+ return;
604
+ const r = this._$AH, D = u === B && r !== B || u.capture !== r.capture || u.once !== r.once || u.passive !== r.passive, s = u !== B && (r === B || D);
605
+ D && this.element.removeEventListener(this.name, this, r), s && this.element.addEventListener(this.name, this, u), this._$AH = u;
606
+ }
607
+ handleEvent(u) {
608
+ var e;
609
+ typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, u) : this._$AH.handleEvent(u);
610
+ }
611
+ }
612
+ class Ee {
613
+ constructor(u, e, r) {
614
+ this.element = u, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = r;
615
+ }
616
+ get _$AU() {
617
+ return this._$AM._$AU;
618
+ }
619
+ _$AI(u) {
620
+ I(this, u);
621
+ }
622
+ }
623
+ const au = V.litHtmlPolyfillSupport;
624
+ au == null || au(Z, K), (V.litHtmlVersions ?? (V.litHtmlVersions = [])).push("3.1.3");
625
+ const Fe = (t, u, e) => {
626
+ const r = (e == null ? void 0 : e.renderBefore) ?? u;
627
+ let D = r._$litPart$;
628
+ if (D === void 0) {
629
+ const s = (e == null ? void 0 : e.renderBefore) ?? null;
630
+ r._$litPart$ = D = new K(u.insertBefore(q(), s), s, void 0, e ?? {});
631
+ }
632
+ return D._$AI(t), D;
633
+ };
634
+ /**
635
+ * @license
636
+ * Copyright 2017 Google LLC
637
+ * SPDX-License-Identifier: BSD-3-Clause
638
+ */
639
+ class H extends k {
640
+ constructor() {
641
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
642
+ }
643
+ createRenderRoot() {
644
+ var e;
645
+ const u = super.createRenderRoot();
646
+ return (e = this.renderOptions).renderBefore ?? (e.renderBefore = u.firstChild), u;
647
+ }
648
+ update(u) {
649
+ const e = this.render();
650
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(u), this._$Do = Fe(e, this.renderRoot, this.renderOptions);
651
+ }
652
+ connectedCallback() {
653
+ var u;
654
+ super.connectedCallback(), (u = this._$Do) == null || u.setConnected(!0);
655
+ }
656
+ disconnectedCallback() {
657
+ var u;
658
+ super.disconnectedCallback(), (u = this._$Do) == null || u.setConnected(!1);
659
+ }
660
+ render() {
661
+ return R;
662
+ }
663
+ }
664
+ var Mu;
665
+ H._$litElement$ = !0, H.finalized = !0, (Mu = globalThis.litElementHydrateSupport) == null || Mu.call(globalThis, { LitElement: H });
666
+ const cu = globalThis.litElementPolyfillSupport;
667
+ cu == null || cu({ LitElement: H });
668
+ (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.5");
669
+ /**
670
+ * @license
671
+ * Copyright 2017 Google LLC
672
+ * SPDX-License-Identifier: BSD-3-Clause
673
+ */
674
+ const le = { attribute: !0, type: String, converter: uu, reflect: !1, hasChanged: pu }, de = (t = le, u, e) => {
675
+ const { kind: r, metadata: D } = e;
676
+ let s = globalThis.litPropertyMetadata.get(D);
677
+ if (s === void 0 && globalThis.litPropertyMetadata.set(D, s = /* @__PURE__ */ new Map()), s.set(e.name, t), r === "accessor") {
678
+ const { name: i } = e;
679
+ return { set(a) {
680
+ const o = u.get.call(this);
681
+ u.set.call(this, a), this.requestUpdate(i, o, t);
682
+ }, init(a) {
683
+ return a !== void 0 && this.P(i, void 0, t), a;
684
+ } };
685
+ }
686
+ if (r === "setter") {
687
+ const { name: i } = e;
688
+ return function(a) {
689
+ const o = this[i];
690
+ u.call(this, a), this.requestUpdate(i, o, t);
1288
691
  };
1289
-
1290
- /** Update a single prop on a given node. */
1291
- function updateObjectProp({
1292
- node,
1293
- key,
1294
- interactables,
1295
- value
1296
- }) {
1297
- // handle and return early if prop is an event
1298
- // (event list from react-three-fiber)
1299
- if (isEventKey(key)) {
1300
- return addEventListener({
1301
- node,
1302
- key,
1303
- interactables,
1304
- value
692
+ }
693
+ throw Error("Unsupported decorator location: " + r);
694
+ };
695
+ function su(t) {
696
+ return (u, e) => typeof e == "object" ? de(t, u, e) : ((r, D, s) => {
697
+ const i = D.hasOwnProperty(s);
698
+ return D.constructor.createProperty(s, i ? { ...r, wrapped: !0 } : r), i ? Object.getOwnPropertyDescriptor(D, s) : void 0;
699
+ })(t, u, e);
700
+ }
701
+ const pe = (t, u, e) => {
702
+ if (!u)
703
+ return;
704
+ const r = Array.isArray(u) ? u : u.match(/([^[.\]])+/g), D = r == null ? void 0 : r.reduce(
705
+ (s, i) => s && s[i],
706
+ t
707
+ );
708
+ return D === void 0 ? e : D;
709
+ };
710
+ function fe(t) {
711
+ if (!t)
712
+ return !1;
713
+ const u = t.constructor && t.constructor.toString().substring(0, 5) === "class";
714
+ if (t.prototype === void 0)
715
+ return u;
716
+ const e = t.prototype.constructor && t.prototype.constructor.toString && t.prototype.constructor.toString().substring(0, 5) === "class";
717
+ return u || e;
718
+ }
719
+ const Be = () => {
720
+ const t = "[object Number]", e = Object.prototype.toString;
721
+ function r(s) {
722
+ return !!s && typeof s == "object";
723
+ }
724
+ return function(i) {
725
+ return typeof i == "number" || r(i) && e.call(i) == t;
726
+ };
727
+ }, me = Be(), ye = (t, u, e) => {
728
+ const r = Array.isArray(u) ? u : u.match(/([^[.\]])+/g);
729
+ r == null || r.reduce((D, s, i) => (D[s] === void 0 && (D[s] = {}), i === r.length - 1 && (D[s] = e), D[s]), t);
730
+ }, Gu = "data-three-uuid", zu = (t, u, e) => {
731
+ var D;
732
+ const r = pe(t, u);
733
+ if (me(e) && (r != null && r.setScalar))
734
+ r.setScalar(+e);
735
+ else if (r != null && r.set)
736
+ if (typeof e == "string") {
737
+ const s = e.split(","), i = s.every((a) => !a.match(/^[^\d,]+$/));
738
+ if ((D = e.toLowerCase().trim().match(/^#[\dabcdef]{3,6}$/)) != null && D.length)
739
+ if (e.length === 4) {
740
+ const a = [e[1], e[1], e[2], e[2], e[3], e[3]].join("");
741
+ r.set(+`0x${a}`);
742
+ } else
743
+ r.set(+`0x${e.slice(1)}`);
744
+ else
745
+ s != null && s.length && i ? r.set(...s.map((a) => +a)) : r.set(e);
746
+ } else {
747
+ const s = Array.isArray(e) ? e : [e];
748
+ r.set(...s);
749
+ }
750
+ else
751
+ ye(t, u, e);
752
+ };
753
+ var ge = Object.defineProperty, $e = (t, u, e, r) => {
754
+ for (var D = void 0, s = t.length - 1, i; s >= 0; s--)
755
+ (i = t[s]) && (D = i(u, e, D) || D);
756
+ return D && ge(u, e, D), D;
757
+ };
758
+ const Vu = "raycast", Nu = [
759
+ Vu,
760
+ "args",
761
+ "data"
762
+ ], Wu = (t) => {
763
+ const u = typeof t == "string" ? m[t] : t;
764
+ if (!fe(u))
765
+ return null;
766
+ class e extends H {
767
+ constructor() {
768
+ super(...arguments), this.args = [], this.instance = null, this.dispose = [], this.mutationObserver = null;
769
+ }
770
+ connectedCallback() {
771
+ super.connectedCallback(), this.mutationObserver = new MutationObserver((s) => {
772
+ s.forEach((i) => {
773
+ if (!i.attributeName)
774
+ return;
775
+ const a = this.attributes.getNamedItem(i.attributeName);
776
+ a && this.updateProperty(a);
1305
777
  });
778
+ }), this.mutationObserver.observe(this, {
779
+ attributes: !0
780
+ }), this.instance = new u(...this.args), this.getAttributeNames().forEach((s) => {
781
+ const i = this.attributes.getNamedItem(s);
782
+ i && this.updateProperty(i);
783
+ }), Array.from(this.attributes).forEach(this.updateProperty.bind(this)), this.instance instanceof m.Object3D && this.setAttribute(Gu, this.instance.uuid);
784
+ const D = this.parentElement;
785
+ if (D.instance) {
786
+ const s = this.instance, i = this.instance, a = this.instance, o = D.instance, F = D.instance;
787
+ s.type.toLowerCase().includes("geometry") && o.geometry ? o.geometry = s : i.type.toLowerCase().includes("material") && o.material ? o.material = i : this.instance instanceof m.Object3D && F.add && F.add(a);
1306
788
  }
1307
- // update THREE property
1308
- // get final key
1309
- const camelKey = key.replace(/-/g, '.');
1310
- const finalKey = propertyShortcuts[camelKey] || camelKey;
1311
- // handle and return early if prop is specific to Vue/Lunchbox
1312
- if (internalLunchboxVueKeys.includes(key) || internalLunchboxVueKeys.includes(finalKey)) return node;
1313
- // everything else should be Three-specific, so let's cancel if this isn't a standard node
1314
- if (!isLunchboxStandardNode(node)) return node;
1315
- // parse $attached values
1316
- if (typeof value === 'string' && value.startsWith('$attached')) {
1317
- const attachedName = value.replace('$attached.', '');
1318
- value = get(node.attached, attachedName, null);
1319
- }
1320
- // save instance
1321
- const target = node.instance;
1322
- // cancel if no target
1323
- if (!target) return node;
1324
- // burrow down until we get property to change
1325
- let liveProperty;
1326
- for (let i = 0; i < nestedPropertiesToCheck.length && !liveProperty; i++) {
1327
- const nestedProperty = nestedPropertiesToCheck[i];
1328
- const fullPath = [nestedProperty, finalKey].filter(Boolean).join('.');
1329
- liveProperty = liveProperty = get(target, fullPath);
1330
- }
1331
- // change property
1332
- // first, save as array in case we need to spread it
1333
- if (liveProperty && isNumber(value) && liveProperty?.setScalar) {
1334
- // if value is a number and the property has a `setScalar` method, use that
1335
- liveProperty.setScalar(value);
1336
- } else if (liveProperty && liveProperty.set) {
1337
- // if property has `set` method, use that (https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#shortcuts)
1338
- const nextValueAsArray = Array.isArray(value) ? value : [value];
1339
- target[finalKey].set(...nextValueAsArray);
1340
- } else if (typeof liveProperty === 'function') {
1341
- // some function properties are set rather than called, so let's handle them
1342
- if (finalKey.toLowerCase() === 'onbeforerender' || finalKey.toLowerCase() === 'onafterrender') {
1343
- target[finalKey] = value;
1344
- } else {
1345
- if (!Array.isArray(value)) {
1346
- throw new Error('Arguments on a declarative method must be wrapped in an array.\nWorks:\n<example :methodCall="[256]" />\nDoesn\'t work:\n<example :methodCall="256" />');
1347
- }
1348
- // if property is a function, let's try calling it
1349
- liveProperty.bind(node.instance)(...value);
1350
- }
1351
- // pass the result to the parent
1352
- // const parent = node.parentNode
1353
- // if (parent) {
1354
- // const parentAsLunchboxNode = parent as Lunchbox.Node
1355
- // parentAsLunchboxNode.attached[finalKey] = result
1356
- // ; (parentAsLunchboxNode.instance as any)[finalKey] = result
1357
- // }
1358
- } else if (get(target, finalKey, undefined) !== undefined) {
1359
- // blank strings evaluate to `true`
1360
- // <mesh castShadow receiveShadow /> will work the same as
1361
- // <mesh :castShadow="true" :receiveShadow="true" />
1362
- set(target, finalKey, value === '' ? true : value);
1363
- } else {
1364
- // if you see this error in production, you might need to add `finalKey`
1365
- // to `internalLunchboxVueKeys` below
1366
- console.log(`No property ${finalKey} found on ${target}`);
1367
- }
1368
- // mark that we need to update if needed
1369
- const targetTypeRaw = target?.texture?.type || target?.type;
1370
- if (typeof targetTypeRaw === 'string') {
1371
- const targetType = targetTypeRaw.toLowerCase();
1372
- switch (true) {
1373
- case targetType.includes('material'):
1374
- target.needsUpdate = true;
1375
- break;
1376
- case targetType.includes('camera') && target.updateProjectionMatrix:
1377
- target.updateProjectionMatrix();
1378
- break;
1379
- }
1380
- }
1381
- return node;
1382
789
  }
1383
- const propertyShortcuts = {
1384
- x: 'position.x',
1385
- y: 'position.y',
1386
- z: 'position.z'
1387
- };
1388
- const nestedPropertiesToCheck = ['', 'parameters'];
1389
- /** props that Lunchbox intercepts and prevents passing to created instances */
1390
- const internalLunchboxVueKeys = ['args', 'attach', 'attachArray', 'is.default', 'isDefault', 'key', 'onAdded',
1391
- // 'onReady',
1392
- 'ref', 'src'];
1393
-
1394
- const autoAttach = ['geometry', 'material'];
1395
- const createElement = (type, isSVG, isCustomizedBuiltin, vnodeProps) => {
1396
- const options = {
1397
- type,
1398
- props: vnodeProps
1399
- };
1400
- // handle dom node
1401
- const isDomNode = isLunchboxDomComponent(options);
1402
- if (isDomNode) {
1403
- const node = createDomNode(options);
1404
- return node;
1405
- }
1406
- // handle standard node
1407
- const node = createNode(options);
1408
- // autoattach
1409
- autoAttach.forEach(key => {
1410
- if (type.toLowerCase().endsWith(key)) {
1411
- node.props.attach = key;
1412
- }
790
+ /** Update an instance's property. When creating a `<mesh position-y="0.5">`, for example, this sets `mesh.position.y = 0.5`. */
791
+ updateProperty(D) {
792
+ const { name: s, value: i } = D;
793
+ let a = s;
794
+ Object.keys(this.instance ?? {}).forEach((d) => {
795
+ d.toLowerCase() === a && (a = d);
1413
796
  });
1414
- // TODO: array autoattach
1415
- return node;
1416
- };
1417
-
1418
- const insert = (child, parent, anchor) => {
1419
- if (!parent) {
1420
- throw new Error('missing parent');
1421
- }
1422
- // add to parent tree node if we have one
1423
- // let effectiveParent = parent ?? ensureRootNode()
1424
- parent.insertBefore(child, anchor);
1425
- // handle comment & text nodes
1426
- if (child.metaType === 'commentMeta' || child.metaType === 'textMeta') {
797
+ const o = a.split("-");
798
+ if (Nu.includes(a) || Nu.includes(o[0]))
1427
799
  return;
800
+ let F = i;
801
+ try {
802
+ F = JSON.parse(i === "" ? "true" : i);
803
+ } catch {
1428
804
  }
1429
- // handle dom element
1430
- if (isLunchboxDomComponent(child)) {
1431
- if (isLunchboxDomComponent(parent) || isLunchboxRootNode(parent)) {
1432
- parent.domElement.appendChild(child.domElement);
1433
- }
1434
- }
1435
- // handle standard nodes
1436
- if (isLunchboxStandardNode(child)) {
1437
- // let effectiveParent = parent
1438
- let effectiveParentNodeType = parent.metaType;
1439
- if (effectiveParentNodeType === 'textMeta' || effectiveParentNodeType === 'commentMeta') {
1440
- const path = parent.getPath();
1441
- for (let i = path.length - 1; i >= 0; i--) {
1442
- if (path[i].metaType !== 'textMeta' && path[i].metaType !== 'commentMeta') {
1443
- parent = path[i];
1444
- break;
1445
- }
1446
- }
1447
- }
1448
- if (isLunchboxStandardNode(child) && child.instance?.isObject3D && isLunchboxStandardNode(parent) && parent.instance?.isObject3D) {
1449
- parent.instance?.add?.(child.instance);
1450
- }
1451
- // add attached props
1452
- if (child?.props?.attach && isLunchboxStandardNode(parent) && parent?.instance) {
1453
- // if this element is a loader and the `src` attribute is being used,
1454
- // let's assume we want to create the loader and run `load`
1455
- const isUsingLoaderSugar = child.type?.toLowerCase().endsWith('loader') && child.props.src && (child.props.attach || child.props.attachArray);
1456
- // run special loader behavior
1457
- if (isUsingLoaderSugar) {
1458
- runLoader(child, parent);
1459
- } else {
1460
- // update attached normally
1461
- attachToParentInstance(child, parent, child.props.attach);
1462
- }
1463
- }
1464
- // fire onAdded event
1465
- if (child.props?.onAdded) {
1466
- child.props.onAdded({
1467
- instance: child.instance
1468
- });
1469
- }
1470
- }
1471
- };
1472
- function runLoader(child, parent) {
1473
- const loader = child.instance;
1474
- // ensure parent has attached spaces ready
1475
- parent.attached = parent.attached || {};
1476
- parent.attachedArray = parent.attachedArray || {};
1477
- // this should never be true, but just in case
1478
- if (!child.props.attach) return;
1479
- if (child.type?.toLowerCase() === 'textureloader') {
1480
- // if this is a texture loader, immediately pass
1481
- // load function to parent attachment
1482
- const textureLoader = loader;
1483
- const inProgressTexture = textureLoader.load(child.props.src);
1484
- attachToParentInstance(child, parent, child.props.attach, inProgressTexture);
1485
- } else {
1486
- // use a standard callback-based loader
1487
- loader.load(child.props.src, loadedData => {
1488
- attachToParentInstance(child, parent, child.props.attach, loadedData);
1489
- }, null, err => {
1490
- throw new Error(err);
1491
- });
1492
- }
805
+ this.instance && zu(this.instance, o, F);
1493
806
  }
1494
- function attachToParentInstance(child, parent, key, value) {
1495
- const finalValueToAttach = value ?? child.instance;
1496
- const parentInstanceAsAny = parent.instance;
1497
- if (child.props.attach === key) {
1498
- parent.attached = {
1499
- [key]: finalValueToAttach,
1500
- ...(parent.attached || {})
1501
- };
1502
- parentInstanceAsAny[key] = value ?? child.instance;
1503
- }
1504
- if (child.props.attachArray === key) {
1505
- if (!parent.attachedArray[child.props.attachArray]) {
1506
- parent.attachedArray[child.props.attachArray] = [];
1507
- }
1508
- parent.attachedArray[child.props.attachArray].push(finalValueToAttach);
1509
- // TODO: implement auto-attaching array
1510
- parentInstanceAsAny[key] = [parentInstanceAsAny[key]];
1511
- }
807
+ disconnectedCallback() {
808
+ super.disconnectedCallback(), (this.instance instanceof m.BufferGeometry || this.instance instanceof m.Material || this.instance instanceof m.Texture) && this.instance.dispose(), this.instance instanceof m.Object3D && this.instance.removeFromParent();
1512
809
  }
1513
-
1514
- const remove = node => {
1515
- if (!node) return;
1516
- // prep subtree
1517
- const subtree = [];
1518
- node.walk(descendant => {
1519
- subtree.push(descendant);
1520
- return true;
1521
- });
1522
- // clean up subtree
1523
- subtree.forEach(n => {
1524
- if (isLunchboxStandardNode(n)) {
1525
- // try to remove three object
1526
- n.instance?.removeFromParent?.();
1527
- // try to dispose three object
1528
- const dispose =
1529
- // calling `dispose` on a scene triggers an error,
1530
- // so let's ignore if this node is a scene
1531
- n.type !== 'scene' && n.instance?.dispose;
1532
- if (dispose) dispose.bind(n.instance)();
1533
- n.instance = null;
1534
- }
1535
- // drop tree node
1536
- n.drop();
1537
- });
1538
- };
1539
-
1540
- /*
1541
- Elements are `create`d from the outside in, then `insert`ed from the inside out.
1542
- */
1543
- const createNodeOps = () => {
1544
- // APP-LEVEL GLOBALS
1545
- // ====================
1546
- // These need to exist at the app level in a place where the node ops can access them.
1547
- // It'd be better to set these via `app.provide` at app creation, but the node ops need access
1548
- // to these values before the app is instantiated, so this is the next-best place for them to exist.
1549
- const interactables = vue.ref([]);
1550
- // NODE OPS
1551
- // ====================
1552
- const nodeOps = {
1553
- createElement,
1554
- createText(text) {
1555
- return createTextNode({
1556
- text
1557
- });
1558
- },
1559
- createComment(text) {
1560
- return createCommentNode({
1561
- text
1562
- });
1563
- },
1564
- insert,
1565
- nextSibling(node) {
1566
- const result = node.nextSibling;
1567
- if (!result) return null;
1568
- return result;
1569
- },
1570
- parentNode(node) {
1571
- const result = node.parentNode;
1572
- if (!result) return null;
1573
- return result;
1574
- },
1575
- patchProp(node, key, prevValue, nextValue) {
1576
- if (isLunchboxDomComponent(node)) {
1577
- // handle DOM node
1578
- if (key === 'style') {
1579
- // special handling for style
1580
- Object.keys(nextValue).forEach(k => {
1581
- node.domElement.style[k] = nextValue[k];
1582
- });
1583
- } else {
1584
- node.domElement.setAttribute(key, nextValue);
1585
- }
1586
- return;
1587
- }
1588
- // ignore if root node, or Lunchbox internal prop
1589
- if (isLunchboxRootNode(node) || key.startsWith('$')) {
1590
- return;
1591
- }
1592
- // otherwise, update prop
1593
- updateObjectProp({
1594
- node: node,
1595
- key,
1596
- interactables,
1597
- value: nextValue
1598
- });
1599
- },
1600
- remove,
1601
- setElementText() {
1602
- // noop
1603
- },
1604
- setText() {
1605
- // noop
1606
- }
1607
- };
1608
- return {
1609
- nodeOps,
1610
- interactables
1611
- };
1612
- };
1613
-
1614
- const BridgeComponent = vue.defineComponent({
1615
- name: 'BridgeComponent',
1616
- props: {
1617
- app: {
1618
- type: Object
1619
- },
1620
- root: {
1621
- type: Object
1622
- },
1623
- appSetup: {
1624
- type: Function,
1625
- default: app => app
1626
- }
1627
- },
1628
- setup(props, ctx) {
1629
- // we need an app or root to mount
1630
- if (!props.app && !props.root) {
1631
- throw new Error('app or root required as <bridge> prop');
1632
- }
1633
- // prep container
1634
- const container = vue.ref();
1635
- // create app
1636
- let app = props.appSetup(props.app ?? createApp(props.root, ctx.attrs));
1637
- // get all provided values - this isn't in the types or docs, so it may be unstable
1638
- const provides = vue.getCurrentInstance()?.provides ?? {};
1639
- // provide values
1640
- Object.keys(provides).forEach(key => {
1641
- app?.provide(key, vue.inject(key));
1642
- });
1643
- // mount
1644
- vue.onMounted(() => {
1645
- app?.mount(container.value);
1646
- });
1647
- // unmount
1648
- vue.onUnmounted(() => {
1649
- app?.unmount();
1650
- app = null;
810
+ /** Render */
811
+ render() {
812
+ return Uu`<slot></slot>`;
813
+ }
814
+ }
815
+ return $e([
816
+ su({ type: Array })
817
+ ], e.prototype, "args"), e;
818
+ };
819
+ function be(t) {
820
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
821
+ }
822
+ var iu = {};
823
+ iu.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
824
+ iu.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
825
+ iu.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
826
+ const Au = iu;
827
+ var _e = {
828
+ isSpaceSeparator(t) {
829
+ return typeof t == "string" && Au.Space_Separator.test(t);
830
+ },
831
+ isIdStartChar(t) {
832
+ return typeof t == "string" && (t >= "a" && t <= "z" || t >= "A" && t <= "Z" || t === "$" || t === "_" || Au.ID_Start.test(t));
833
+ },
834
+ isIdContinueChar(t) {
835
+ return typeof t == "string" && (t >= "a" && t <= "z" || t >= "A" && t <= "Z" || t >= "0" && t <= "9" || t === "$" || t === "_" || t === "‌" || t === "‍" || Au.ID_Continue.test(t));
836
+ },
837
+ isDigit(t) {
838
+ return typeof t == "string" && /[0-9]/.test(t);
839
+ },
840
+ isHexDigit(t) {
841
+ return typeof t == "string" && /[0-9A-Fa-f]/.test(t);
842
+ }
843
+ };
844
+ const p = _e;
845
+ let hu, y, _, tu, x, g, f, fu, W;
846
+ var ve = function(u, e) {
847
+ hu = String(u), y = "start", _ = [], tu = 0, x = 1, g = 0, f = void 0, fu = void 0, W = void 0;
848
+ do
849
+ f = we(), xe[y]();
850
+ while (f.type !== "eof");
851
+ return typeof e == "function" ? Eu({ "": W }, "", e) : W;
852
+ };
853
+ function Eu(t, u, e) {
854
+ const r = t[u];
855
+ if (r != null && typeof r == "object")
856
+ if (Array.isArray(r))
857
+ for (let D = 0; D < r.length; D++) {
858
+ const s = String(D), i = Eu(r, s, e);
859
+ i === void 0 ? delete r[s] : Object.defineProperty(r, s, {
860
+ value: i,
861
+ writable: !0,
862
+ enumerable: !0,
863
+ configurable: !0
1651
864
  });
1652
- return () => vue.createVNode("div", {
1653
- "ref": container
1654
- }, null);
1655
865
  }
1656
- });
1657
-
1658
- const bridge = {
1659
- install(app) {
1660
- // register wrapper component
1661
- app.component('lunchbox', BridgeComponent);
866
+ else
867
+ for (const D in r) {
868
+ const s = Eu(r, D, e);
869
+ s === void 0 ? delete r[D] : Object.defineProperty(r, D, {
870
+ value: s,
871
+ writable: !0,
872
+ enumerable: !0,
873
+ configurable: !0
874
+ });
1662
875
  }
1663
- };
1664
-
1665
- /** The current camera as a computed value. */
1666
- const useCamera = () => vue.inject(appCameraKey);
1667
- /** Run a function using the current camera when it's present. */
1668
- const onCameraReady = cb => {
1669
- const existing = useCamera();
1670
- if (existing.value) {
1671
- cb(existing.value);
876
+ return e.call(t, u, r);
877
+ }
878
+ let A, c, G, b, C;
879
+ function we() {
880
+ for (A = "default", c = "", G = !1, b = 1; ; ) {
881
+ C = v();
882
+ const t = qu[A]();
883
+ if (t)
884
+ return t;
885
+ }
886
+ }
887
+ function v() {
888
+ if (hu[tu])
889
+ return String.fromCodePoint(hu.codePointAt(tu));
890
+ }
891
+ function n() {
892
+ const t = v();
893
+ return t === `
894
+ ` ? (x++, g = 0) : t ? g += t.length : g++, t && (tu += t.length), t;
895
+ }
896
+ const qu = {
897
+ default() {
898
+ switch (C) {
899
+ case " ":
900
+ case "\v":
901
+ case "\f":
902
+ case " ":
903
+ case " ":
904
+ case "\uFEFF":
905
+ case `
906
+ `:
907
+ case "\r":
908
+ case "\u2028":
909
+ case "\u2029":
910
+ n();
1672
911
  return;
1673
- }
1674
- let stopWatch = null;
1675
- stopWatch = vue.watch(useCamera(), newVal => {
1676
- if (newVal) {
1677
- cb(newVal);
1678
- stopWatch?.();
1679
- }
1680
- });
1681
- };
1682
- /** The current renderer as a computed value. */
1683
- const useRenderer = () => vue.inject(appRenderersKey);
1684
- /** Run a function using the current renderer when it's present. */
1685
- const onRendererReady = cb => {
1686
- const existing = useRenderer();
1687
- if (existing.value) {
1688
- cb(existing.value);
912
+ case "/":
913
+ n(), A = "comment";
1689
914
  return;
1690
- }
1691
- let stopWatch = null;
1692
- stopWatch = vue.watch(useRenderer(), newVal => {
1693
- if (newVal) {
1694
- cb(newVal);
1695
- stopWatch?.();
1696
- }
1697
- }, {
1698
- immediate: true
1699
- });
1700
- };
1701
- /** The current scene as a computed value. */
1702
- const useScene = () => vue.inject(appSceneKey);
1703
- /** Run a function using the current scene when it's present. */
1704
- const onSceneReady = cb => {
1705
- const existing = useScene();
1706
- if (existing.value) {
1707
- cb(existing.value);
915
+ case void 0:
916
+ return n(), h("eof");
917
+ }
918
+ if (p.isSpaceSeparator(C)) {
919
+ n();
920
+ return;
921
+ }
922
+ return qu[y]();
923
+ },
924
+ comment() {
925
+ switch (C) {
926
+ case "*":
927
+ n(), A = "multiLineComment";
1708
928
  return;
929
+ case "/":
930
+ n(), A = "singleLineComment";
931
+ return;
932
+ }
933
+ throw E(n());
934
+ },
935
+ multiLineComment() {
936
+ switch (C) {
937
+ case "*":
938
+ n(), A = "multiLineCommentAsterisk";
939
+ return;
940
+ case void 0:
941
+ throw E(n());
942
+ }
943
+ n();
944
+ },
945
+ multiLineCommentAsterisk() {
946
+ switch (C) {
947
+ case "*":
948
+ n();
949
+ return;
950
+ case "/":
951
+ n(), A = "default";
952
+ return;
953
+ case void 0:
954
+ throw E(n());
955
+ }
956
+ n(), A = "multiLineComment";
957
+ },
958
+ singleLineComment() {
959
+ switch (C) {
960
+ case `
961
+ `:
962
+ case "\r":
963
+ case "\u2028":
964
+ case "\u2029":
965
+ n(), A = "default";
966
+ return;
967
+ case void 0:
968
+ return n(), h("eof");
969
+ }
970
+ n();
971
+ },
972
+ value() {
973
+ switch (C) {
974
+ case "{":
975
+ case "[":
976
+ return h("punctuator", n());
977
+ case "n":
978
+ return n(), T("ull"), h("null", null);
979
+ case "t":
980
+ return n(), T("rue"), h("boolean", !0);
981
+ case "f":
982
+ return n(), T("alse"), h("boolean", !1);
983
+ case "-":
984
+ case "+":
985
+ n() === "-" && (b = -1), A = "sign";
986
+ return;
987
+ case ".":
988
+ c = n(), A = "decimalPointLeading";
989
+ return;
990
+ case "0":
991
+ c = n(), A = "zero";
992
+ return;
993
+ case "1":
994
+ case "2":
995
+ case "3":
996
+ case "4":
997
+ case "5":
998
+ case "6":
999
+ case "7":
1000
+ case "8":
1001
+ case "9":
1002
+ c = n(), A = "decimalInteger";
1003
+ return;
1004
+ case "I":
1005
+ return n(), T("nfinity"), h("numeric", 1 / 0);
1006
+ case "N":
1007
+ return n(), T("aN"), h("numeric", NaN);
1008
+ case '"':
1009
+ case "'":
1010
+ G = n() === '"', c = "", A = "string";
1011
+ return;
1012
+ }
1013
+ throw E(n());
1014
+ },
1015
+ identifierNameStartEscape() {
1016
+ if (C !== "u")
1017
+ throw E(n());
1018
+ n();
1019
+ const t = Fu();
1020
+ switch (t) {
1021
+ case "$":
1022
+ case "_":
1023
+ break;
1024
+ default:
1025
+ if (!p.isIdStartChar(t))
1026
+ throw Tu();
1027
+ break;
1028
+ }
1029
+ c += t, A = "identifierName";
1030
+ },
1031
+ identifierName() {
1032
+ switch (C) {
1033
+ case "$":
1034
+ case "_":
1035
+ case "‌":
1036
+ case "‍":
1037
+ c += n();
1038
+ return;
1039
+ case "\\":
1040
+ n(), A = "identifierNameEscape";
1041
+ return;
1042
+ }
1043
+ if (p.isIdContinueChar(C)) {
1044
+ c += n();
1045
+ return;
1046
+ }
1047
+ return h("identifier", c);
1048
+ },
1049
+ identifierNameEscape() {
1050
+ if (C !== "u")
1051
+ throw E(n());
1052
+ n();
1053
+ const t = Fu();
1054
+ switch (t) {
1055
+ case "$":
1056
+ case "_":
1057
+ case "‌":
1058
+ case "‍":
1059
+ break;
1060
+ default:
1061
+ if (!p.isIdContinueChar(t))
1062
+ throw Tu();
1063
+ break;
1064
+ }
1065
+ c += t, A = "identifierName";
1066
+ },
1067
+ sign() {
1068
+ switch (C) {
1069
+ case ".":
1070
+ c = n(), A = "decimalPointLeading";
1071
+ return;
1072
+ case "0":
1073
+ c = n(), A = "zero";
1074
+ return;
1075
+ case "1":
1076
+ case "2":
1077
+ case "3":
1078
+ case "4":
1079
+ case "5":
1080
+ case "6":
1081
+ case "7":
1082
+ case "8":
1083
+ case "9":
1084
+ c = n(), A = "decimalInteger";
1085
+ return;
1086
+ case "I":
1087
+ return n(), T("nfinity"), h("numeric", b * (1 / 0));
1088
+ case "N":
1089
+ return n(), T("aN"), h("numeric", NaN);
1090
+ }
1091
+ throw E(n());
1092
+ },
1093
+ zero() {
1094
+ switch (C) {
1095
+ case ".":
1096
+ c += n(), A = "decimalPoint";
1097
+ return;
1098
+ case "e":
1099
+ case "E":
1100
+ c += n(), A = "decimalExponent";
1101
+ return;
1102
+ case "x":
1103
+ case "X":
1104
+ c += n(), A = "hexadecimal";
1105
+ return;
1106
+ }
1107
+ return h("numeric", b * 0);
1108
+ },
1109
+ decimalInteger() {
1110
+ switch (C) {
1111
+ case ".":
1112
+ c += n(), A = "decimalPoint";
1113
+ return;
1114
+ case "e":
1115
+ case "E":
1116
+ c += n(), A = "decimalExponent";
1117
+ return;
1118
+ }
1119
+ if (p.isDigit(C)) {
1120
+ c += n();
1121
+ return;
1122
+ }
1123
+ return h("numeric", b * Number(c));
1124
+ },
1125
+ decimalPointLeading() {
1126
+ if (p.isDigit(C)) {
1127
+ c += n(), A = "decimalFraction";
1128
+ return;
1129
+ }
1130
+ throw E(n());
1131
+ },
1132
+ decimalPoint() {
1133
+ switch (C) {
1134
+ case "e":
1135
+ case "E":
1136
+ c += n(), A = "decimalExponent";
1137
+ return;
1138
+ }
1139
+ if (p.isDigit(C)) {
1140
+ c += n(), A = "decimalFraction";
1141
+ return;
1142
+ }
1143
+ return h("numeric", b * Number(c));
1144
+ },
1145
+ decimalFraction() {
1146
+ switch (C) {
1147
+ case "e":
1148
+ case "E":
1149
+ c += n(), A = "decimalExponent";
1150
+ return;
1151
+ }
1152
+ if (p.isDigit(C)) {
1153
+ c += n();
1154
+ return;
1155
+ }
1156
+ return h("numeric", b * Number(c));
1157
+ },
1158
+ decimalExponent() {
1159
+ switch (C) {
1160
+ case "+":
1161
+ case "-":
1162
+ c += n(), A = "decimalExponentSign";
1163
+ return;
1164
+ }
1165
+ if (p.isDigit(C)) {
1166
+ c += n(), A = "decimalExponentInteger";
1167
+ return;
1168
+ }
1169
+ throw E(n());
1170
+ },
1171
+ decimalExponentSign() {
1172
+ if (p.isDigit(C)) {
1173
+ c += n(), A = "decimalExponentInteger";
1174
+ return;
1175
+ }
1176
+ throw E(n());
1177
+ },
1178
+ decimalExponentInteger() {
1179
+ if (p.isDigit(C)) {
1180
+ c += n();
1181
+ return;
1182
+ }
1183
+ return h("numeric", b * Number(c));
1184
+ },
1185
+ hexadecimal() {
1186
+ if (p.isHexDigit(C)) {
1187
+ c += n(), A = "hexadecimalInteger";
1188
+ return;
1189
+ }
1190
+ throw E(n());
1191
+ },
1192
+ hexadecimalInteger() {
1193
+ if (p.isHexDigit(C)) {
1194
+ c += n();
1195
+ return;
1196
+ }
1197
+ return h("numeric", b * Number(c));
1198
+ },
1199
+ string() {
1200
+ switch (C) {
1201
+ case "\\":
1202
+ n(), c += Se();
1203
+ return;
1204
+ case '"':
1205
+ if (G)
1206
+ return n(), h("string", c);
1207
+ c += n();
1208
+ return;
1209
+ case "'":
1210
+ if (!G)
1211
+ return n(), h("string", c);
1212
+ c += n();
1213
+ return;
1214
+ case `
1215
+ `:
1216
+ case "\r":
1217
+ throw E(n());
1218
+ case "\u2028":
1219
+ case "\u2029":
1220
+ Ne(C);
1221
+ break;
1222
+ case void 0:
1223
+ throw E(n());
1224
+ }
1225
+ c += n();
1226
+ },
1227
+ start() {
1228
+ switch (C) {
1229
+ case "{":
1230
+ case "[":
1231
+ return h("punctuator", n());
1232
+ }
1233
+ A = "value";
1234
+ },
1235
+ beforePropertyName() {
1236
+ switch (C) {
1237
+ case "$":
1238
+ case "_":
1239
+ c = n(), A = "identifierName";
1240
+ return;
1241
+ case "\\":
1242
+ n(), A = "identifierNameStartEscape";
1243
+ return;
1244
+ case "}":
1245
+ return h("punctuator", n());
1246
+ case '"':
1247
+ case "'":
1248
+ G = n() === '"', A = "string";
1249
+ return;
1250
+ }
1251
+ if (p.isIdStartChar(C)) {
1252
+ c += n(), A = "identifierName";
1253
+ return;
1254
+ }
1255
+ throw E(n());
1256
+ },
1257
+ afterPropertyName() {
1258
+ if (C === ":")
1259
+ return h("punctuator", n());
1260
+ throw E(n());
1261
+ },
1262
+ beforePropertyValue() {
1263
+ A = "value";
1264
+ },
1265
+ afterPropertyValue() {
1266
+ switch (C) {
1267
+ case ",":
1268
+ case "}":
1269
+ return h("punctuator", n());
1270
+ }
1271
+ throw E(n());
1272
+ },
1273
+ beforeArrayValue() {
1274
+ if (C === "]")
1275
+ return h("punctuator", n());
1276
+ A = "value";
1277
+ },
1278
+ afterArrayValue() {
1279
+ switch (C) {
1280
+ case ",":
1281
+ case "]":
1282
+ return h("punctuator", n());
1283
+ }
1284
+ throw E(n());
1285
+ },
1286
+ end() {
1287
+ throw E(n());
1288
+ }
1289
+ };
1290
+ function h(t, u) {
1291
+ return {
1292
+ type: t,
1293
+ value: u,
1294
+ line: x,
1295
+ column: g
1296
+ };
1297
+ }
1298
+ function T(t) {
1299
+ for (const u of t) {
1300
+ if (v() !== u)
1301
+ throw E(n());
1302
+ n();
1303
+ }
1304
+ }
1305
+ function Se() {
1306
+ switch (v()) {
1307
+ case "b":
1308
+ return n(), "\b";
1309
+ case "f":
1310
+ return n(), "\f";
1311
+ case "n":
1312
+ return n(), `
1313
+ `;
1314
+ case "r":
1315
+ return n(), "\r";
1316
+ case "t":
1317
+ return n(), " ";
1318
+ case "v":
1319
+ return n(), "\v";
1320
+ case "0":
1321
+ if (n(), p.isDigit(v()))
1322
+ throw E(n());
1323
+ return "\0";
1324
+ case "x":
1325
+ return n(), Pe();
1326
+ case "u":
1327
+ return n(), Fu();
1328
+ case `
1329
+ `:
1330
+ case "\u2028":
1331
+ case "\u2029":
1332
+ return n(), "";
1333
+ case "\r":
1334
+ return n(), v() === `
1335
+ ` && n(), "";
1336
+ case "1":
1337
+ case "2":
1338
+ case "3":
1339
+ case "4":
1340
+ case "5":
1341
+ case "6":
1342
+ case "7":
1343
+ case "8":
1344
+ case "9":
1345
+ throw E(n());
1346
+ case void 0:
1347
+ throw E(n());
1348
+ }
1349
+ return n();
1350
+ }
1351
+ function Pe() {
1352
+ let t = "", u = v();
1353
+ if (!p.isHexDigit(u) || (t += n(), u = v(), !p.isHexDigit(u)))
1354
+ throw E(n());
1355
+ return t += n(), String.fromCodePoint(parseInt(t, 16));
1356
+ }
1357
+ function Fu() {
1358
+ let t = "", u = 4;
1359
+ for (; u-- > 0; ) {
1360
+ const e = v();
1361
+ if (!p.isHexDigit(e))
1362
+ throw E(n());
1363
+ t += n();
1364
+ }
1365
+ return String.fromCodePoint(parseInt(t, 16));
1366
+ }
1367
+ const xe = {
1368
+ start() {
1369
+ if (f.type === "eof")
1370
+ throw M();
1371
+ Cu();
1372
+ },
1373
+ beforePropertyName() {
1374
+ switch (f.type) {
1375
+ case "identifier":
1376
+ case "string":
1377
+ fu = f.value, y = "afterPropertyName";
1378
+ return;
1379
+ case "punctuator":
1380
+ Y();
1381
+ return;
1382
+ case "eof":
1383
+ throw M();
1384
+ }
1385
+ },
1386
+ afterPropertyName() {
1387
+ if (f.type === "eof")
1388
+ throw M();
1389
+ y = "beforePropertyValue";
1390
+ },
1391
+ beforePropertyValue() {
1392
+ if (f.type === "eof")
1393
+ throw M();
1394
+ Cu();
1395
+ },
1396
+ beforeArrayValue() {
1397
+ if (f.type === "eof")
1398
+ throw M();
1399
+ if (f.type === "punctuator" && f.value === "]") {
1400
+ Y();
1401
+ return;
1402
+ }
1403
+ Cu();
1404
+ },
1405
+ afterPropertyValue() {
1406
+ if (f.type === "eof")
1407
+ throw M();
1408
+ switch (f.value) {
1409
+ case ",":
1410
+ y = "beforePropertyName";
1411
+ return;
1412
+ case "}":
1413
+ Y();
1414
+ }
1415
+ },
1416
+ afterArrayValue() {
1417
+ if (f.type === "eof")
1418
+ throw M();
1419
+ switch (f.value) {
1420
+ case ",":
1421
+ y = "beforeArrayValue";
1422
+ return;
1423
+ case "]":
1424
+ Y();
1425
+ }
1426
+ },
1427
+ end() {
1428
+ }
1429
+ };
1430
+ function Cu() {
1431
+ let t;
1432
+ switch (f.type) {
1433
+ case "punctuator":
1434
+ switch (f.value) {
1435
+ case "{":
1436
+ t = {};
1437
+ break;
1438
+ case "[":
1439
+ t = [];
1440
+ break;
1709
1441
  }
1710
- let stopWatch = null;
1711
- stopWatch = vue.watch(useScene(), newVal => {
1712
- if (newVal) {
1713
- cb(newVal);
1714
- stopWatch?.();
1715
- }
1716
- }, {
1717
- immediate: true
1718
- });
1719
- };
1720
- // CUSTOM RENDER SUPPORT
1721
- // ====================
1722
- /** Set a custom render function, overriding the Lunchbox app's default render function.
1723
- * Changing this requires the user to manually render their scene.
1724
- *
1725
- * Invokes immediately - use `useCustomRender().setCustomRender`
1726
- * if you need to call somewhere outside of `setup`.
1727
- */
1728
- const setCustomRender = render => {
1729
- useCustomRender()?.setCustomRender?.(render);
1730
- };
1731
- /** Clear the active app's custom render function.
1732
- *
1733
- * Invokes immediately - use `useCustomRender().clearCustomRender`
1734
- * if you need to call somewhere outside of `setup`.
1735
- */
1736
- const clearCustomRender = () => {
1737
- useCustomRender()?.clearCustomRender?.();
1738
- };
1739
- /** Provides `setCustomRender` and `clearCustomRender` functions to be called in a non-`setup` context. */
1740
- const useCustomRender = () => {
1741
- return {
1742
- /** Set a custom render function, overriding the Lunchbox app's default render function.
1743
- * Changing this requires the user to manually render their scene. */
1744
- setCustomRender: vue.inject(setCustomRenderKey),
1745
- /** Clear the active app's custom render function. */
1746
- clearCustomRender: vue.inject(clearCustomRenderKey)
1747
- };
1748
- };
1749
- /** Use app-level globals. */
1750
- const useGlobals = () => vue.inject(globalsInjectionKey);
1751
- /** Construct a function to update your app-level globals.
1752
- *
1753
- * ```js
1754
- * // in setup():
1755
- * const updateGlobals = useUpdateGlobals()
1756
- *
1757
- * // ...later, to update the device pixel resolution...
1758
- * updateGlobals({ dpr: 2 })
1759
- * ```
1760
- */
1761
- const useUpdateGlobals = () => vue.inject(updateGlobalsInjectionKey);
1762
- /** Update app-level globals.
1763
- *
1764
- * Invokes immediately - use `useUpdateGlobals`
1765
- * if you need to call somewhere outside of `setup`.
1766
- */
1767
- const updateGlobals = newValue => {
1768
- useUpdateGlobals()?.(newValue);
1769
- };
1770
- /** Use the current Lunchbox app. Usually used internally by Lunchbox. */
1771
- const useApp = () => vue.inject(appKey);
1772
- /** Obtain a list of the start callback functions. Usually used internally by Lunchbox. */
1773
- const useStartCallbacks = () => vue.inject(startCallbackKey);
1774
- /** Run a given callback once when the Lunchbox app starts. Include an index to
1775
- * splice the callback at that index in the callback queue. */
1776
- const onStart = (cb, index = Infinity) => {
1777
- const callbacks = useStartCallbacks();
1778
- if (index === Infinity) {
1779
- callbacks?.push(cb);
1780
- } else {
1781
- callbacks?.splice(index, 0, cb);
1782
- }
1783
- };
1784
- /** Obtain a list of interactable objects (registered via onClick, onHover, etc events). Usually used internally by Lunchbox. */
1785
- const useLunchboxInteractables = () => vue.inject(lunchboxInteractables);
1786
- /** Build a computed instance-getter from a specified ref. Defaults to a `toRaw`'d result. */
1787
- const getInstance = (target, raw = true) => vue.computed(() => {
1788
- const output = target.value?.$el?.instance ?? target.value?.instance ?? null;
1789
- if (output && raw) return vue.toRaw(output);
1790
- return output;
1442
+ break;
1443
+ case "null":
1444
+ case "boolean":
1445
+ case "numeric":
1446
+ case "string":
1447
+ t = f.value;
1448
+ break;
1449
+ }
1450
+ if (W === void 0)
1451
+ W = t;
1452
+ else {
1453
+ const u = _[_.length - 1];
1454
+ Array.isArray(u) ? u.push(t) : Object.defineProperty(u, fu, {
1455
+ value: t,
1456
+ writable: !0,
1457
+ enumerable: !0,
1458
+ configurable: !0
1791
1459
  });
1792
- // CREATE APP
1793
- // ====================
1794
- const createApp = (root, rootProps = {}) => {
1795
- const {
1796
- nodeOps,
1797
- interactables
1798
- } = createNodeOps();
1799
- const app = vue.createRenderer(nodeOps).createApp(root, rootProps);
1800
- // provide Lunchbox interaction handlers flag (modified when user references events via
1801
- // @click, etc)
1802
- app.provide(lunchboxInteractables, interactables);
1803
- // register all components
1804
- // ====================
1805
- Object.keys(components).forEach(key => {
1806
- app?.component(key, components[key]);
1807
- });
1808
- // provide custom renderer functions
1809
- // ====================
1810
- app.provide(setCustomRenderKey, render => {
1811
- app.setCustomRender(render);
1812
- });
1813
- app.provide(clearCustomRenderKey, () => {
1814
- app.clearCustomRender();
1815
- });
1816
- // before render
1817
- // ====================
1818
- const beforeRender = [];
1819
- app.provide(beforeRenderKey, beforeRender);
1820
- app.provide(onBeforeRenderKey, (cb, index = Infinity) => {
1821
- if (index === Infinity) {
1822
- beforeRender.push(cb);
1823
- } else {
1824
- beforeRender.splice(index, 0, cb);
1825
- }
1826
- });
1827
- app.provide(offBeforeRenderKey, cb => {
1828
- if (isFinite(cb)) {
1829
- beforeRender.splice(cb, 1);
1830
- } else {
1831
- const idx = beforeRender.findIndex(v => v == cb);
1832
- if (idx !== -1) {
1833
- beforeRender.splice(idx, 1);
1460
+ }
1461
+ if (t !== null && typeof t == "object")
1462
+ _.push(t), Array.isArray(t) ? y = "beforeArrayValue" : y = "beforePropertyName";
1463
+ else {
1464
+ const u = _[_.length - 1];
1465
+ u == null ? y = "end" : Array.isArray(u) ? y = "afterArrayValue" : y = "afterPropertyValue";
1466
+ }
1467
+ }
1468
+ function Y() {
1469
+ _.pop();
1470
+ const t = _[_.length - 1];
1471
+ t == null ? y = "end" : Array.isArray(t) ? y = "afterArrayValue" : y = "afterPropertyValue";
1472
+ }
1473
+ function E(t) {
1474
+ return ru(t === void 0 ? `JSON5: invalid end of input at ${x}:${g}` : `JSON5: invalid character '${Ju(t)}' at ${x}:${g}`);
1475
+ }
1476
+ function M() {
1477
+ return ru(`JSON5: invalid end of input at ${x}:${g}`);
1478
+ }
1479
+ function Tu() {
1480
+ return g -= 5, ru(`JSON5: invalid identifier character at ${x}:${g}`);
1481
+ }
1482
+ function Ne(t) {
1483
+ console.warn(`JSON5: '${Ju(t)}' in strings is not valid ECMAScript; consider escaping`);
1484
+ }
1485
+ function Ju(t) {
1486
+ const u = {
1487
+ "'": "\\'",
1488
+ '"': '\\"',
1489
+ "\\": "\\\\",
1490
+ "\b": "\\b",
1491
+ "\f": "\\f",
1492
+ "\n": "\\n",
1493
+ "\r": "\\r",
1494
+ " ": "\\t",
1495
+ "\v": "\\v",
1496
+ "\0": "\\0",
1497
+ "\u2028": "\\u2028",
1498
+ "\u2029": "\\u2029"
1499
+ };
1500
+ if (u[t])
1501
+ return u[t];
1502
+ if (t < " ") {
1503
+ const e = t.charCodeAt(0).toString(16);
1504
+ return "\\x" + ("00" + e).substring(e.length);
1505
+ }
1506
+ return t;
1507
+ }
1508
+ function ru(t) {
1509
+ const u = new SyntaxError(t);
1510
+ return u.lineNumber = x, u.columnNumber = g, u;
1511
+ }
1512
+ const Te = /* @__PURE__ */ be(ve);
1513
+ var Me = Object.defineProperty, Bu = (t, u, e, r) => {
1514
+ for (var D = void 0, s = t.length - 1, i; s >= 0; s--)
1515
+ (i = t[s]) && (D = i(u, e, D) || D);
1516
+ return D && Me(u, e, D), D;
1517
+ };
1518
+ const Oe = "orthographic", mu = class mu extends H {
1519
+ constructor() {
1520
+ super(), this.scratchV2 = new m.Vector2(), this.three = {
1521
+ scene: new m.Scene(),
1522
+ camera: null,
1523
+ renderer: new m.WebGLRenderer({
1524
+ antialias: !0,
1525
+ alpha: !0
1526
+ })
1527
+ }, this.background = null, this.dpr = 2, this.sizePolicy = "full", this.raycaster = new m.Raycaster(), this.raycastPool = [], this.frame = 1 / 0, this.resizeObserver = new ResizeObserver((u) => {
1528
+ u.forEach(({ target: e, contentRect: r }) => {
1529
+ if (e === this && (this.three.renderer.setSize(r.width * this.dpr, r.height * this.dpr), this.three.camera)) {
1530
+ const D = r.width / r.height;
1531
+ if (this.three.camera.type.toLowerCase() === "perspectivecamera")
1532
+ this.three.camera.aspect = D, this.three.camera.updateProjectionMatrix();
1533
+ else if (this.three.camera.type.toLowerCase() === "orthographiccamera") {
1534
+ const s = r.height / r.width, i = 10;
1535
+ this.three.camera.top = s * i, this.three.camera.bottom = -s * i, this.three.camera.right = i, this.three.camera.left = -i, this.three.camera.updateProjectionMatrix();
1834
1536
  }
1537
+ this.renderThree();
1835
1538
  }
1836
1539
  });
1837
- // after render
1838
- // ====================
1839
- const afterRender = [];
1840
- app.provide(afterRenderKey, afterRender);
1841
- app.provide(onAfterRenderKey, (cb, index = Infinity) => {
1842
- if (index === Infinity) {
1843
- afterRender.push(cb);
1844
- } else {
1845
- afterRender.splice(index, 0, cb);
1846
- }
1847
- });
1848
- app.provide(offAfterRenderKey, cb => {
1849
- if (isFinite(cb)) {
1850
- afterRender.splice(cb, 1);
1851
- } else {
1852
- const idx = afterRender.findIndex(v => v == cb);
1853
- if (idx !== -1) {
1854
- afterRender.splice(idx, 1);
1855
- }
1856
- }
1540
+ });
1541
+ }
1542
+ /** To run on start. */
1543
+ connectedCallback() {
1544
+ super.connectedCallback(), this.getAttribute("dpr") === null && (this.dpr = window.devicePixelRatio), this.getAttribute(Oe) !== null ? this.three.camera = new m.OrthographicCamera() : this.three.camera = new m.PerspectiveCamera(75), ["scene", "camera", "renderer"].forEach((u) => {
1545
+ const e = Te(this.getAttribute(u) ?? "{}");
1546
+ Object.entries(e).forEach(([r, D]) => {
1547
+ this.three[u] && zu(this.three[u], r.split("-"), D);
1857
1548
  });
1858
- // save app-level components
1859
- // ====================
1860
- app.config.globalProperties.lunchbox = vue.reactive({
1861
- afterRender,
1862
- beforeRender,
1863
- camera: null,
1864
- dpr: 1,
1865
- frameId: -1,
1866
- renderer: null,
1867
- scene: null,
1868
- watchStopHandle: null
1869
- // TODO: inputActive, mousePos
1549
+ }), this.resizeObserver.observe(this), this.background !== null && (this.three.scene.background = new m.Color(this.background)), this.three.renderer.domElement.addEventListener("pointermove", this.onPointerMove.bind(this)), this.three.renderer.domElement.addEventListener("mousemove", this.onPointerMove.bind(this)), this.three.renderer.domElement.addEventListener("click", this.onClick.bind(this)), this.updateLoop();
1550
+ }
1551
+ disconnectedCallback() {
1552
+ this.three.renderer.domElement.removeEventListener("pointermove", this.onPointerMove.bind(this)), this.three.renderer.domElement.removeEventListener("click", this.onClick.bind(this)), this.three.renderer.dispose(), this.resizeObserver.unobserve(this), cancelAnimationFrame(this.frame);
1553
+ }
1554
+ handleDefaultSlotChange(u) {
1555
+ u.target.assignedElements().forEach((e) => {
1556
+ const r = e;
1557
+ if (r.instance instanceof m.Object3D) {
1558
+ let D = !1;
1559
+ if (this.three.scene.traverse((s) => {
1560
+ D || s.uuid === r.instance.uuid && (D = !0);
1561
+ }), D)
1562
+ return;
1563
+ this.three.scene.add(r.instance), e.getAttributeNames().includes(Vu) && this.raycastPool.push(r.instance);
1564
+ }
1565
+ }), this.renderThree();
1566
+ }
1567
+ runRaycast(u) {
1568
+ if (!this.raycastPool.length || !this.three.camera)
1569
+ return [];
1570
+ const e = this.scratchV2.clone().set(
1571
+ u.clientX / (this.three.renderer.domElement.width / this.dpr) * 2 - 1,
1572
+ -(u.clientY / (this.three.renderer.domElement.height / this.dpr)) * 2 + 1
1573
+ );
1574
+ return this.raycaster.setFromCamera(e, this.three.camera), this.raycaster.intersectObjects(this.raycastPool).map((s) => ({
1575
+ intersect: s,
1576
+ // TODO: cache result of this query selector somewhere?
1577
+ element: this.querySelector(`[${Gu}="${s.object.uuid}"]`)
1578
+ }));
1579
+ }
1580
+ // Pointer movement
1581
+ // ==================
1582
+ onPointerMove(u) {
1583
+ this.runRaycast.bind(this)(u).forEach((r) => {
1584
+ var D, s, i, a;
1585
+ u.type === "pointermove" ? ((D = r.element) == null || D.dispatchEvent(new PointerEvent("pointermove")), (s = r.element) == null || s.dispatchEvent(new CustomEvent(Le, { detail: r }))) : u.type === "mousemove" && ((i = r.element) == null || i.dispatchEvent(new MouseEvent("mousemove")), (a = r.element) == null || a.dispatchEvent(new CustomEvent(ke, { detail: r })));
1586
+ });
1587
+ }
1588
+ // Click handling
1589
+ // ==================
1590
+ onClick(u) {
1591
+ let e = [];
1592
+ if (u instanceof TouchEvent) {
1593
+ const r = u.touches[0];
1594
+ e = this.runRaycast.bind(this)(r), e.forEach((D) => {
1595
+ var s;
1596
+ (s = D.element) == null || s.dispatchEvent(new TouchEvent("touchstart"));
1870
1597
  });
1871
- // provide app-level globals & globals update method
1872
- // ====================
1873
- app.provide(globalsInjectionKey, app.config.globalProperties.lunchbox);
1874
- app.provide(updateGlobalsInjectionKey, newGlobals => {
1875
- Object.keys(newGlobals).forEach(key => {
1876
- const typedKey = key;
1877
- // TODO: fix
1878
- app.config.globalProperties.lunchbox[typedKey] = newGlobals[typedKey];
1879
- });
1598
+ } else
1599
+ e = this.runRaycast.bind(this)(u), e.forEach((r) => {
1600
+ var D;
1601
+ (D = r.element) == null || D.dispatchEvent(new MouseEvent("click"));
1880
1602
  });
1881
- // frame ID (used for update functions)
1882
- // ====================
1883
- app.provide(frameIdKey, app.config.globalProperties.lunchbox.frameId);
1884
- // watch stop handler (used for conditional update loop)
1885
- // ====================
1886
- app.provide(watchStopHandleKey, app.config.globalProperties.lunchbox.watchStopHandle);
1887
- // update mount function to match Lunchbox.Node
1888
- // ====================
1889
- const {
1890
- mount
1891
- } = app;
1892
- app.mount = (root, ...args) => {
1893
- // find DOM element to use as app root
1894
- const domElement = typeof root === 'string' ? document.querySelector(root) : root;
1895
- // create or find root node
1896
- const rootNode = new exports.MiniDom.RendererRootNode({
1897
- domElement,
1898
- isLunchboxRootNode: true,
1899
- name: 'root',
1900
- metaType: 'rootMeta',
1901
- type: 'root',
1902
- uuid: 'LUNCHBOX_ROOT'
1903
- });
1904
- app.rootNode = rootNode;
1905
- app.provide(appRootNodeKey, rootNode);
1906
- const mounted = mount(rootNode, ...args);
1907
- return mounted;
1908
- };
1909
- // embed .extend function
1910
- // ====================
1911
- app.extend = targets => {
1912
- extend({
1913
- app: app,
1914
- ...targets
1915
- });
1916
- return app;
1917
- };
1918
- // start callback functions
1919
- // ====================
1920
- const startCallbacks = [];
1921
- app.provide(startCallbackKey, startCallbacks);
1922
- // prep for custom render support
1923
- // ====================
1924
- app.setCustomRender = newRender => {
1925
- if (app) {
1926
- app.customRender = newRender;
1927
- }
1928
- };
1929
- // add custom render removal
1930
- app.clearCustomRender = () => {
1931
- if (app) {
1932
- app.customRender = null;
1933
- }
1934
- };
1935
- // provide app
1936
- // ====================
1937
- app.provide(appKey, app);
1938
- app.provide(appRenderersKey, vue.computed(() => app.config.globalProperties.lunchbox.renderer));
1939
- app.provide(appSceneKey, vue.computed(() => app.config.globalProperties.lunchbox.scene));
1940
- app.provide(appCameraKey, vue.computed(() => app.config.globalProperties.lunchbox.camera));
1941
- app._props;
1942
- // done
1943
- return app;
1944
- };
1945
-
1946
- exports.addEventListener = addEventListener;
1947
- exports.afterRenderKey = afterRenderKey;
1948
- exports.appCameraKey = appCameraKey;
1949
- exports.appKey = appKey;
1950
- exports.appRenderersKey = appRenderersKey;
1951
- exports.appRootNodeKey = appRootNodeKey;
1952
- exports.appSceneKey = appSceneKey;
1953
- exports.beforeRenderKey = beforeRenderKey;
1954
- exports.cancelUpdate = cancelUpdate;
1955
- exports.cancelUpdateSource = cancelUpdateSource;
1956
- exports.clearCustomRender = clearCustomRender;
1957
- exports.clearCustomRenderKey = clearCustomRenderKey;
1958
- exports.createApp = createApp;
1959
- exports.createCommentNode = createCommentNode;
1960
- exports.createDomNode = createDomNode;
1961
- exports.createNode = createNode;
1962
- exports.createTextNode = createTextNode;
1963
- exports.extend = extend;
1964
- exports.find = find;
1965
- exports.frameIdKey = frameIdKey;
1966
- exports.getInstance = getInstance;
1967
- exports.globalsInjectionKey = globalsInjectionKey;
1968
- exports.instantiateThreeObject = instantiateThreeObject;
1969
- exports.isMinidomNode = isMinidomNode;
1970
- exports.lunchbox = bridge;
1971
- exports.lunchboxInteractables = lunchboxInteractables;
1972
- exports.nestedPropertiesToCheck = nestedPropertiesToCheck;
1973
- exports.offAfterRender = offAfterRender;
1974
- exports.offAfterRenderKey = offAfterRenderKey;
1975
- exports.offBeforeRender = offBeforeRender;
1976
- exports.offBeforeRenderKey = offBeforeRenderKey;
1977
- exports.onAfterRender = onAfterRender;
1978
- exports.onAfterRenderKey = onAfterRenderKey;
1979
- exports.onBeforeRender = onBeforeRender;
1980
- exports.onBeforeRenderKey = onBeforeRenderKey;
1981
- exports.onCameraReady = onCameraReady;
1982
- exports.onRendererReady = onRendererReady;
1983
- exports.onSceneReady = onSceneReady;
1984
- exports.onStart = onStart;
1985
- exports.setCustomRender = setCustomRender;
1986
- exports.setCustomRenderKey = setCustomRenderKey;
1987
- exports.startCallbackKey = startCallbackKey;
1988
- exports.update = update;
1989
- exports.updateGlobals = updateGlobals;
1990
- exports.updateGlobalsInjectionKey = updateGlobalsInjectionKey;
1991
- exports.updateObjectProp = updateObjectProp;
1992
- exports.useAfterRender = useAfterRender;
1993
- exports.useApp = useApp;
1994
- exports.useBeforeRender = useBeforeRender;
1995
- exports.useCamera = useCamera;
1996
- exports.useCancelUpdate = useCancelUpdate;
1997
- exports.useCancelUpdateSource = useCancelUpdateSource;
1998
- exports.useCustomRender = useCustomRender;
1999
- exports.useGlobals = useGlobals;
2000
- exports.useLunchboxInteractables = useLunchboxInteractables;
2001
- exports.useRenderer = useRenderer;
2002
- exports.useScene = useScene;
2003
- exports.useStartCallbacks = useStartCallbacks;
2004
- exports.useUpdateGlobals = useUpdateGlobals;
2005
- exports.watchStopHandleKey = watchStopHandleKey;
1603
+ e.forEach((r) => {
1604
+ var D;
1605
+ (D = r.element) == null || D.dispatchEvent(new CustomEvent(He, { detail: r }));
1606
+ });
1607
+ }
1608
+ // TODO: Only kick if required
1609
+ updateLoop() {
1610
+ this.renderThree(), this.frame = requestAnimationFrame(this.updateLoop.bind(this));
1611
+ }
1612
+ /** Render the 3D scene */
1613
+ renderThree() {
1614
+ this.three.camera && this.three.renderer.render(this.three.scene, this.three.camera);
1615
+ }
1616
+ render() {
1617
+ return Uu`
1618
+ <slot @slotchange=${this.handleDefaultSlotChange}></slot>
1619
+ ${this.three.renderer.domElement}
1620
+ `;
1621
+ }
1622
+ };
1623
+ mu.styles = Xu`
1624
+ :host {
1625
+ width: 100%;
1626
+ height: 100%;
1627
+ display: block;
1628
+ }
2006
1629
 
2007
- }));
1630
+ canvas {
1631
+ width: 100%;
1632
+ height: 100%;
1633
+ max-width: 100%;
1634
+ max-height: 100%;
1635
+ }
1636
+ `;
1637
+ let U = mu;
1638
+ Bu([
1639
+ su()
1640
+ ], U.prototype, "background");
1641
+ Bu([
1642
+ su()
1643
+ ], U.prototype, "dpr");
1644
+ Bu([
1645
+ su()
1646
+ ], U.prototype, "sizePolicy");
1647
+ const Ie = ({
1648
+ prependList: t = []
1649
+ } = {}) => {
1650
+ customElements.get("three-lunchbox") || customElements.define("three-lunchbox", U), [...t, ...Ou].forEach((u) => {
1651
+ const e = Zu(u);
1652
+ if (customElements.get(e))
1653
+ return;
1654
+ const r = Wu(u);
1655
+ r && customElements.define(e, r);
1656
+ });
1657
+ }, Ue = (t, u) => {
1658
+ if (customElements.get(t)) {
1659
+ console.log(`${t} already registered as a custom element. Try a different name if registering is still required.`);
1660
+ return;
1661
+ }
1662
+ const e = Wu(u);
1663
+ e && customElements.define(t, e);
1664
+ }, Le = "threepointermove", ke = "threemousemove", He = "threeclick", Zu = (t) => {
1665
+ let u = t.split(/\.?(?=[A-Z])/).join("-").toLowerCase().replace(/-g-l-/, "-gl-");
1666
+ return u.includes("-") || (u = `three-${u}`), u;
1667
+ }, je = Ou.map(Zu);
1668
+ export {
1669
+ He as THREE_CLICK_EVENT_NAME,
1670
+ ke as THREE_MOUSE_MOVE_EVENT_NAME,
1671
+ Le as THREE_POINTER_MOVE_EVENT_NAME,
1672
+ U as ThreeLunchbox,
1673
+ Ou as autoComponents,
1674
+ Ue as extend,
1675
+ Ie as initLunchbox,
1676
+ je as webComponentNames
1677
+ };