@lukekaalim/act-three 8.1.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lukekaalim/act-three
2
2
 
3
+ ## 8.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 41b49aa: Upgraded NodeBuilder to pass element during destruction, fixed Sprites not being assigned materials in act-three, and act-three objects will set ref to null on destruction
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [41b49aa]
12
+ - @lukekaalim/act-backstage@4.0.0
13
+ - @lukekaalim/act-web@6.2.1
14
+
3
15
  ## 8.1.0
4
16
 
5
17
  ### Minor Changes
package/builder.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { NodeBuilder } from "@lukekaalim/act-backstage";
2
2
  import { Object3D } from "three";
3
3
  import { registry } from "./elements";
4
- import { Component, h, specialNodeTypes } from "@lukekaalim/act";
4
+ import { Component, h, specialNodeTypes, WriteOnlyRef } from "@lukekaalim/act";
5
5
 
6
6
  export const ThreeJSRoot: Component = ({ children }) => h(specialNodeTypes.render, { type: 'threejs' }, children);
7
7
 
@@ -22,8 +22,11 @@ export const createThreeJSBuilder = (rootObject: Object3D | null = null): NodeBu
22
22
  link(el, parent) {
23
23
  parent && parent.add(el)
24
24
  },
25
- destroy(el) {
26
- if (el.parent)
27
- el.removeFromParent()
25
+ destroy(obj, el) {
26
+ if (obj.parent)
27
+ obj.removeFromParent()
28
+ if (el.props.ref) {
29
+ (el.props.ref as WriteOnlyRef<null>).set(null);
30
+ }
28
31
  },
29
32
  })
package/elements.ts CHANGED
@@ -31,7 +31,8 @@ export type PropsFromClass<T extends three.Object3D> = {
31
31
  //onAdded?: (self: T) => void,
32
32
  //onRemoved?: (self: T) => void,
33
33
 
34
- ref?: T extends three.Points<any, any, any> ? WriteOnlyRef<three.Points<any, any, any>> : WriteOnlyRef<T>,
34
+ // Crude fix for Points, which has a fucked generic
35
+ ref?: T extends three.Points<any, any, any> ? WriteOnlyRef<null | three.Points<any, any, any>> : WriteOnlyRef<T | null>,
35
36
  }
36
37
  & (T extends three.Mesh | three.Points | three.Line ? DrawableProps : {})
37
38
  & (T extends three.Sprite ? SpriteProps : {})
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@lukekaalim/act-three",
3
3
  "main": "index.ts",
4
4
  "type": "module",
5
- "version": "8.1.0",
5
+ "version": "8.2.0",
6
6
  "dependencies": {
7
7
  "@lukekaalim/act": "^5.0.0",
8
- "@lukekaalim/act-backstage": "^3.2.1",
8
+ "@lukekaalim/act-backstage": "^4.0.0",
9
9
  "@lukekaalim/act-recon": "^4.0.1",
10
- "@lukekaalim/act-web": "^6.0.0",
10
+ "@lukekaalim/act-web": "^6.2.1",
11
11
  "@types/three": ">= 0.185.0"
12
12
  },
13
13
  "peerDependencies": {
package/props.ts CHANGED
@@ -46,6 +46,12 @@ export const setProps = (object: three.Object3D, props: PropsFromClass<three.Obj
46
46
  if (meshProps.material)
47
47
  object.material = meshProps.material;
48
48
  }
49
+ if (object instanceof three.Sprite) {
50
+ const spriteProps = props as PropsFromClass<three.Sprite>;
51
+ if (spriteProps.material)
52
+ // A little bit of cheating here ;)
53
+ object.material = spriteProps.material as three.SpriteMaterial;
54
+ }
49
55
 
50
56
  if (object instanceof three.PerspectiveCamera) {
51
57
  const perspectiveCameraProps = props as PropsFromClass<three.PerspectiveCamera>;