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,175 +0,0 @@
1
- // list of all components to register out of the box
2
- export const autoGeneratedComponents = [
3
- // ThreeJS basics
4
- 'mesh',
5
- 'instancedMesh',
6
- 'scene',
7
- 'sprite',
8
- 'object3D',
9
-
10
- // geometry
11
- 'instancedBufferGeometry',
12
- 'bufferGeometry',
13
- 'boxBufferGeometry',
14
- 'circleBufferGeometry',
15
- 'coneBufferGeometry',
16
- 'cylinderBufferGeometry',
17
- 'dodecahedronBufferGeometry',
18
- 'extrudeBufferGeometry',
19
- 'icosahedronBufferGeometry',
20
- 'latheBufferGeometry',
21
- 'octahedronBufferGeometry',
22
- 'parametricBufferGeometry',
23
- 'planeBufferGeometry',
24
- 'polyhedronBufferGeometry',
25
- 'ringBufferGeometry',
26
- 'shapeBufferGeometry',
27
- 'sphereBufferGeometry',
28
- 'tetrahedronBufferGeometry',
29
- 'textBufferGeometry',
30
- 'torusBufferGeometry',
31
- 'torusKnotBufferGeometry',
32
- 'tubeBufferGeometry',
33
- 'wireframeGeometry',
34
- 'parametricGeometry',
35
- 'tetrahedronGeometry',
36
- 'octahedronGeometry',
37
- 'icosahedronGeometry',
38
- 'dodecahedronGeometry',
39
- 'polyhedronGeometry',
40
- 'tubeGeometry',
41
- 'torusKnotGeometry',
42
- 'torusGeometry',
43
- // textgeometry has been moved to /examples/jsm/geometries/TextGeometry
44
- // 'textGeometry',
45
- 'sphereGeometry',
46
- 'ringGeometry',
47
- 'planeGeometry',
48
- 'latheGeometry',
49
- 'shapeGeometry',
50
- 'extrudeGeometry',
51
- 'edgesGeometry',
52
- 'coneGeometry',
53
- 'cylinderGeometry',
54
- 'circleGeometry',
55
- 'boxGeometry',
56
-
57
- // materials
58
- 'material',
59
- 'shadowMaterial',
60
- 'spriteMaterial',
61
- 'rawShaderMaterial',
62
- 'shaderMaterial',
63
- 'pointsMaterial',
64
- 'meshPhysicalMaterial',
65
- 'meshStandardMaterial',
66
- 'meshPhongMaterial',
67
- 'meshToonMaterial',
68
- 'meshNormalMaterial',
69
- 'meshLambertMaterial',
70
- 'meshDepthMaterial',
71
- 'meshDistanceMaterial',
72
- 'meshBasicMaterial',
73
- 'meshMatcapMaterial',
74
- 'lineDashedMaterial',
75
- 'lineBasicMaterial',
76
-
77
- // lights
78
- 'light',
79
- 'spotLightShadow',
80
- 'spotLight',
81
- 'pointLight',
82
- 'rectAreaLight',
83
- 'hemisphereLight',
84
- 'directionalLightShadow',
85
- 'directionalLight',
86
- 'ambientLight',
87
- 'lightShadow',
88
- 'ambientLightProbe',
89
- 'hemisphereLightProbe',
90
- 'lightProbe',
91
-
92
- // textures
93
- 'texture',
94
- 'videoTexture',
95
- 'dataTexture',
96
- 'dataTexture3D',
97
- 'compressedTexture',
98
- 'cubeTexture',
99
- 'canvasTexture',
100
- 'depthTexture',
101
-
102
- // Texture loaders
103
- 'textureLoader',
104
-
105
- // misc
106
- 'group',
107
- 'catmullRomCurve3',
108
- 'points',
109
- 'raycaster',
110
-
111
- // helpers
112
- 'cameraHelper',
113
-
114
- // cameras
115
- 'camera',
116
- 'perspectiveCamera',
117
- 'orthographicCamera',
118
- 'cubeCamera',
119
- 'arrayCamera',
120
-
121
- // renderers
122
- 'webGLRenderer',
123
-
124
- /*
125
- // List copied from r3f:
126
- // https://github.com/pmndrs/react-three-fiber/blob/master/packages/fiber/src/three-types.ts
127
-
128
- // NOT IMPLEMENTED (can be added via Extend - docs.lunchboxjs.com/components/extend/):
129
- audioListener: AudioListenerProps
130
- positionalAudio: PositionalAudioProps
131
-
132
- lOD: LODProps
133
- skinnedMesh: SkinnedMeshProps
134
- skeleton: SkeletonProps
135
- bone: BoneProps
136
- lineSegments: LineSegmentsProps
137
- lineLoop: LineLoopProps
138
- // see `audio`
139
- // line: LineProps
140
- immediateRenderObject: ImmediateRenderObjectProps
141
-
142
- // primitive
143
- primitive: PrimitiveProps
144
-
145
- // helpers
146
- spotLightHelper: SpotLightHelperProps
147
- skeletonHelper: SkeletonHelperProps
148
- pointLightHelper: PointLightHelperProps
149
- hemisphereLightHelper: HemisphereLightHelperProps
150
- gridHelper: GridHelperProps
151
- polarGridHelper: PolarGridHelperProps
152
- directionalLightHelper: DirectionalLightHelperProps
153
- boxHelper: BoxHelperProps
154
- box3Helper: Box3HelperProps
155
- planeHelper: PlaneHelperProps
156
- arrowHelper: ArrowHelperProps
157
- axesHelper: AxesHelperProps
158
-
159
-
160
- // misc
161
- vector2: Vector2Props
162
- vector3: Vector3Props
163
- vector4: Vector4Props
164
- euler: EulerProps
165
- matrix3: Matrix3Props
166
- matrix4: Matrix4Props
167
- quaternion: QuaternionProps
168
- bufferAttribute: BufferAttributeProps
169
- instancedBufferAttribute: InstancedBufferAttributeProps
170
- color: ColorProps
171
- fog: FogProps
172
- fogExp2: FogExp2Props
173
- shape: ShapeProps
174
- */
175
- ]
@@ -1,31 +0,0 @@
1
- import { h, defineComponent } from 'vue'
2
- import { LunchboxWrapper } from './LunchboxWrapper/LunchboxWrapper'
3
- import { autoGeneratedComponents } from './autoGeneratedComponents'
4
- import type { Lunch } from '../types'
5
-
6
- export const catalogue: Lunch.Catalogue = {}
7
-
8
- // component creation utility
9
- const createComponent = (tag: string) =>
10
- defineComponent({
11
- inheritAttrs: false,
12
- name: tag,
13
- setup(props, context) {
14
- return () => {
15
- return h(tag, context.attrs, context.slots?.default?.() || [])
16
- }
17
- },
18
- })
19
-
20
- // turn components into registered map
21
- const processed = autoGeneratedComponents
22
- .map(createComponent)
23
- .reduce((acc, curr) => {
24
- acc[curr.name] = curr
25
- return acc
26
- }, {} as Record<string, ReturnType<typeof defineComponent>>)
27
-
28
- export const components = {
29
- ...processed,
30
- Lunchbox: LunchboxWrapper,
31
- }
@@ -1,71 +0,0 @@
1
- import { isLunchboxRootNode } from '../utils'
2
- import { instantiateThreeObject, MiniDom } from '.'
3
- import type { Lunch } from '..'
4
-
5
- /** Create a new Lunchbox comment node. */
6
- export function createCommentNode(options: Partial<Lunch.CommentMeta> = {}) {
7
- const defaults: Omit<Lunch.CommentMeta, keyof Lunch.MetaBase> = {
8
- text: options.text ?? '',
9
- }
10
- return new MiniDom.RendererCommentNode({
11
- ...defaults,
12
- ...options,
13
- metaType: 'commentMeta',
14
- })
15
- }
16
-
17
- /** Create a new DOM node. */
18
- export function createDomNode(options: Partial<Lunch.DomMeta> = {}) {
19
- const domElement = document.createElement(options.type ?? '')
20
- const defaults: Omit<Lunch.DomMeta, keyof Lunch.MetaBase> = {
21
- domElement,
22
- }
23
-
24
- const node = new MiniDom.RendererDomNode({
25
- ...defaults,
26
- ...options,
27
- metaType: 'domMeta',
28
- })
29
- return node
30
- }
31
-
32
- /** Create a new Lunchbox text node. */
33
- export function createTextNode(options: Partial<Lunch.TextMeta> = {}) {
34
- const defaults: Omit<Lunch.CommentMeta, keyof Lunch.MetaBase> = {
35
- text: options.text ?? '',
36
- }
37
- return new MiniDom.RendererTextNode({
38
- ...options,
39
- ...defaults,
40
- metaType: 'textMeta',
41
- })
42
- }
43
-
44
- /** Create a new Lunchbox standard node. */
45
- export function createNode<T extends object = THREE.Object3D>(
46
- options: Partial<Lunch.StandardMeta<T>> = {},
47
- props: Lunch.LunchboxMetaProps = {}
48
- ) {
49
- const defaults: Omit<Lunch.StandardMeta<T>, keyof Lunch.MetaBase> = {
50
- attached: options.attached ?? [],
51
- attachedArray: options.attachedArray ?? {},
52
- instance: options.instance ?? null,
53
- }
54
- const node = new MiniDom.RendererStandardNode<T>({
55
- ...options,
56
- ...defaults,
57
- metaType: 'standardMeta',
58
- })
59
-
60
- if (node.type && !isLunchboxRootNode(node) && !node.instance) {
61
- node.instance = instantiateThreeObject({
62
- ...node,
63
- props: {
64
- ...node.props,
65
- ...props,
66
- },
67
- })
68
- }
69
-
70
- return node
71
- }
@@ -1,25 +0,0 @@
1
- import { h, defineComponent } from 'vue'
2
- import { catalogue } from '../components'
3
- import type { Lunch } from '..'
4
-
5
- const createComponent = (tag: string) =>
6
- defineComponent({
7
- inheritAttrs: false,
8
- name: tag,
9
- render() {
10
- return h(tag, this.$attrs, this.$slots?.default?.() || [])
11
- },
12
- })
13
-
14
- export const extend = ({
15
- app,
16
- ...targets
17
- }: {
18
- app: Lunch.App
19
- [key: string]: any
20
- }) => {
21
- Object.keys(targets).forEach((key) => {
22
- app.component(key, createComponent(key))
23
- catalogue[key] = targets[key]
24
- })
25
- }
package/src/core/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './createNode'
2
- export * from './interaction'
3
- export * from './extend'
4
- export * from './instantiateThreeObject'
5
- export * from './minidom'
6
- export * from './update'
7
- export * from './updateObjectProp'
@@ -1,37 +0,0 @@
1
- import { catalogue } from '../../components'
2
- import * as THREE from 'three'
3
- import { processPropAsArray } from './processProps'
4
- import type { Lunch } from '../..'
5
-
6
- export function instantiateThreeObject<T>(node: Lunch.StandardMeta<T>) {
7
- if (!node.type) return null
8
-
9
- // what class will we be instantiating?
10
- const uppercaseType = node.type[0].toUpperCase() + node.type.slice(1)
11
- const translatedType = uppercaseType.replace(/Lunchbox$/, '')
12
- const targetClass =
13
- catalogue[node.type] ||
14
- (THREE as any)[uppercaseType] ||
15
- catalogue[translatedType] ||
16
- (THREE as any)[translatedType]
17
- if (!targetClass)
18
- throw `${uppercaseType} is not part of the THREE namespace! Did you forget to extend? import {extend} from 'lunchbox'; extend({app, YourComponent, ...})`
19
-
20
- // what args have we been provided?
21
- const args: Array<any> = node.props.args ?? []
22
-
23
- // replace $attached values with their instances
24
- // we need to guarantee everything comes back as an array so we can spread $attachedArrays,
25
- // so we'll use processPropAsArray
26
- const argsWrappedInArrays = args.map((arg: any) => {
27
- return processPropAsArray({ node, prop: arg })
28
- })
29
- let processedArgs = [] as Array<any>
30
- argsWrappedInArrays.forEach((arr) => {
31
- processedArgs = processedArgs.concat(arr)
32
- })
33
-
34
- const instance = new targetClass(...processedArgs)
35
-
36
- return instance as T
37
- }
@@ -1,40 +0,0 @@
1
- import type { Lunch } from '../..'
2
-
3
- /** Process props into either themselves or the $attached value */
4
- export function processProp<T, U = THREE.Object3D>({
5
- node,
6
- prop,
7
- }: {
8
- node: Lunch.StandardMeta<U>
9
- prop: any
10
- }) {
11
- // return $attachedArray value if needed
12
- if (typeof prop === 'string' && prop.startsWith('$attachedArray')) {
13
- return node.attachedArray[
14
- prop.replace('$attachedArray.', '')
15
- ] as any as T
16
- }
17
-
18
- // return $attached value if needed
19
- if (typeof prop === 'string' && prop.startsWith('$attached')) {
20
- return node.attached[prop.replace('$attached.', '')] as T
21
- }
22
-
23
- // otherwise, return plain value
24
- return prop as T
25
- }
26
-
27
- export function processPropAsArray<T, U = THREE.Object3D>({
28
- node,
29
- prop,
30
- }: {
31
- node: Lunch.StandardMeta<U>
32
- prop: any
33
- }) {
34
- const isAttachedArray =
35
- typeof prop === 'string' && prop.startsWith('$attachedArray')
36
- const output = processProp<T, U>({ node, prop })
37
- return Array.isArray(output) && isAttachedArray
38
- ? (output as Array<T>)
39
- : [output]
40
- }
@@ -1,55 +0,0 @@
1
- import type { Ref } from 'vue'
2
- import type { Lunch } from '..'
3
-
4
- /** Add an event listener to the given node. Also creates the event teardown function and any necessary raycaster/interaction dictionary updates. */
5
- export function addEventListener({
6
- node,
7
- key,
8
- interactables,
9
- value,
10
- }: {
11
- node: Lunch.Node
12
- key: Lunch.EventKey
13
- interactables: Ref<Lunch.Node[]>
14
- value: Lunch.EventCallback
15
- }) {
16
- // create new records for this key if needed
17
- if (!node.eventListeners[key]) {
18
- node.eventListeners[key] = []
19
- }
20
- if (!node.eventListenerRemoveFunctions[key]) {
21
- node.eventListenerRemoveFunctions[key] = []
22
- }
23
-
24
- // add event listener
25
- node.eventListeners[key].push(value)
26
-
27
- // if we need it, let's get/create the main raycaster
28
- if (interactionsRequiringRaycaster.includes(key)) {
29
- if (node.instance && !interactables.value.includes(node)) {
30
- // add to interactables
31
- interactables.value.push(node)
32
- node.eventListenerRemoveFunctions[key].push(() => {
33
- // remove from interactables
34
- const idx = interactables.value.indexOf(node)
35
- if (idx !== -1) {
36
- interactables.value.splice(idx, 1)
37
- }
38
- })
39
- }
40
- }
41
-
42
- return node
43
- }
44
-
45
- const interactionsRequiringRaycaster = [
46
- 'onClick',
47
- 'onPointerUp',
48
- 'onPointerDown',
49
- 'onPointerOver',
50
- 'onPointerOut',
51
- 'onPointerEnter',
52
- 'onPointerLeave',
53
- 'onPointerMove',
54
- // 'onPointerMissed',
55
- ]
@@ -1,256 +0,0 @@
1
- import { v4 as createUuid } from 'uuid'
2
- import type { Lunch } from '..'
3
-
4
- // MiniDom recreates DOM node properties and methods.
5
- // Since Vue 3 is a DOM-first framework, many of its nodeOps depend on
6
- // properties and methods the DOM naturally contains. MiniDom recreates
7
- // those properties (as well as a few from the tree-model npm package)
8
- // to make a DOM-like but otherwise agnostic hierarchy structure.
9
- export namespace MiniDom {
10
- export class BaseNode {
11
- constructor(
12
- options: Partial<BaseNode> = {},
13
- parent?: MiniDom.BaseNode
14
- ) {
15
- this.parentNode = options?.parentNode ?? parent ?? null
16
- this.minidomType = 'MinidomBaseNode'
17
- this.uuid = options?.uuid ?? createUuid()
18
-
19
- // allNodes.push(this)
20
- }
21
- uuid: Lunch.Uuid
22
-
23
- // DOM FEATURES
24
- // ====================
25
- parentNode: MiniDom.BaseNode | null
26
-
27
- get nextSibling(): MiniDom.BaseNode | null {
28
- if (!this.parentNode) return null
29
-
30
- const idx = this.parentNode.children.findIndex(
31
- (n) => n.uuid === this.uuid
32
- )
33
- // return next sibling if we're present and not the last child of the parent
34
- if (idx !== -1 && idx < this.parentNode.children.length - 1) {
35
- return this.parentNode.children[idx + 1]
36
- }
37
-
38
- return null
39
- }
40
-
41
- insertBefore(
42
- child: MiniDom.BaseNode,
43
- anchor?: MiniDom.BaseNode | null
44
- ) {
45
- child.removeAsChildFromAnyParents()
46
- child.parentNode = this
47
- const anchorIdx = this.children.findIndex(
48
- (n) => n.uuid === anchor?.uuid
49
- )
50
- if (anchorIdx !== -1) {
51
- this.children.splice(anchorIdx, 0, child)
52
- } else {
53
- this.children.push(child)
54
- }
55
- }
56
- removeChild(child: MiniDom.BaseNode) {
57
- const idx = this.children.findIndex((n) => n?.uuid === child?.uuid)
58
- if (idx !== -1) {
59
- this.children.splice(idx, 1)
60
- }
61
- }
62
-
63
- // TREE FEATURES
64
- // ====================
65
- children = [] as MiniDom.BaseNode[]
66
- addChild(child: MiniDom.BaseNode) {
67
- if (child) {
68
- // remove child from any other parents
69
- child.removeAsChildFromAnyParents()
70
-
71
- // add to this node
72
- child.parentNode = this
73
- this.insertBefore(child, null)
74
- }
75
- return this
76
- }
77
- /** Get the array of Nodes representing the path from the root to this Node (inclusive). */
78
- getPath() {
79
- const output = [] as BaseNode[]
80
- let current = this as BaseNode | null
81
- while (current) {
82
- output.unshift(current)
83
- current = current.parentNode
84
- }
85
- return output
86
- }
87
-
88
- /** Drop this node. Removes parent's knowledge of this node
89
- * and resets this node's internal parent. */
90
- drop() {
91
- // remove as child
92
- this.removeAsChildFromAnyParents()
93
- // remove parent
94
- this.parentNode = null
95
- }
96
-
97
- /** Walk over the entire subtree. Return falsey value in callback to end early. */
98
- // TODO: depth-first vs breadth-first
99
- walk(callback: (item: MiniDom.BaseNode) => boolean) {
100
- const queue = [this, ...this.children] as MiniDom.BaseNode[]
101
- const traversed: MiniDom.BaseNode[] = []
102
- let canContinue = true
103
- while (queue.length && canContinue) {
104
- const current = queue.shift()
105
- if (current) {
106
- if (traversed.includes(current)) continue
107
-
108
- traversed.push(current)
109
- queue.push(
110
- ...current.children.filter(
111
- (child) => !traversed.includes(child)
112
- )
113
- )
114
- canContinue = callback(current)
115
- } else {
116
- canContinue = false
117
- }
118
- }
119
- }
120
-
121
- // INTERNAL FEATURES
122
- // ====================
123
- minidomType: MiniDom.NodeType
124
-
125
- removeAsChildFromAnyParents() {
126
- this.parentNode?.removeChild(this)
127
- }
128
- }
129
-
130
- export class RendererBaseNode
131
- extends MiniDom.BaseNode
132
- implements Lunch.MetaBase
133
- {
134
- constructor(
135
- options: Partial<Lunch.MetaBase> = {},
136
- parent?: MiniDom.BaseNode
137
- ) {
138
- super(options, parent)
139
- this.minidomType = 'RendererNode'
140
-
141
- this.eventListeners = {}
142
- this.eventListenerRemoveFunctions = {}
143
- this.name = options.name ?? ''
144
- this.metaType = options.metaType ?? 'standardMeta'
145
- this.props = options.props ?? []
146
- this.type = options.type ?? ''
147
- }
148
-
149
- eventListeners: Record<string, Lunch.EventCallback[]>
150
- eventListenerRemoveFunctions: Record<string, Function[]>
151
- name: string | null
152
- metaType: Lunch.MetaType
153
- props: Lunch.LunchboxMetaProps
154
- type: string | null
155
-
156
- drop() {
157
- super.drop()
158
- // handle remove functions
159
- Object.keys(this.eventListenerRemoveFunctions).forEach((key) => {
160
- this.eventListenerRemoveFunctions[key].forEach((func) => func())
161
- })
162
- }
163
- }
164
-
165
- // ====================
166
- // SPECIFIC RENDERER NODES BELOW
167
- // ====================
168
-
169
- export class RendererRootNode
170
- extends MiniDom.RendererBaseNode
171
- implements Lunch.RootMeta
172
- {
173
- constructor(
174
- options: Partial<Lunch.RootMeta> = {},
175
- parent?: MiniDom.BaseNode
176
- ) {
177
- super(options, parent)
178
- this.domElement =
179
- options.domElement ?? document.createElement('div')
180
- }
181
-
182
- domElement: HTMLElement
183
- isLunchboxRootNode = true
184
- }
185
-
186
- export class RendererCommentNode
187
- extends MiniDom.RendererBaseNode
188
- implements Lunch.CommentMeta
189
- {
190
- constructor(
191
- options: Partial<Lunch.CommentMeta> = {},
192
- parent?: MiniDom.BaseNode
193
- ) {
194
- super(options, parent)
195
- this.text = options.text ?? ''
196
- }
197
-
198
- text: string
199
- }
200
-
201
- export class RendererDomNode
202
- extends MiniDom.RendererBaseNode
203
- implements Lunch.DomMeta
204
- {
205
- constructor(
206
- options: Partial<Lunch.DomMeta> = {},
207
- parent?: MiniDom.BaseNode
208
- ) {
209
- super(options, parent)
210
- this.domElement =
211
- options.domElement ?? document.createElement('div')
212
- }
213
-
214
- domElement: HTMLElement
215
- }
216
-
217
- export class RendererTextNode
218
- extends MiniDom.RendererBaseNode
219
- implements Lunch.TextMeta
220
- {
221
- constructor(
222
- options: Partial<Lunch.TextMeta> = {},
223
- parent?: MiniDom.BaseNode
224
- ) {
225
- super(options, parent)
226
- this.text = options.text ?? ''
227
- }
228
-
229
- text: string
230
- }
231
-
232
- export class RendererStandardNode<T = THREE.Object3D>
233
- extends MiniDom.RendererBaseNode
234
- implements Lunch.StandardMeta<T>
235
- {
236
- constructor(
237
- options: Partial<Lunch.StandardMeta<T>> = {},
238
- parent?: MiniDom.BaseNode
239
- ) {
240
- super(options, parent)
241
- this.attached = options.attached ?? []
242
- this.attachedArray = options.attachedArray ?? {}
243
- this.instance = options.instance ?? null
244
- }
245
-
246
- attached: { [key: string]: any }
247
- attachedArray: { [key: string]: Array<any> }
248
- instance: T | null
249
- }
250
-
251
- export type NodeType = 'MinidomBaseNode' | 'RendererNode' | 'RootNode'
252
- }
253
-
254
- export function isMinidomNode(item: any): item is MiniDom.RendererBaseNode {
255
- return (item as MiniDom.BaseNode)?.minidomType === 'RendererNode'
256
- }