@lukekaalim/act-three 8.0.3 → 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,35 @@
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
+
15
+ ## 8.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 2ed02cf: Breaking! Change how useRef works, no longer compatible with React-style.
20
+
21
+ New API has `.get` and `.set` properties in order to better type ReadOnlyRef and WriteOnlyRef.
22
+
23
+ Add primitive registry to web, remove old element API and replace with "html" and "svg" element maps
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [2ed02cf]
28
+ - @lukekaalim/act-web@6.0.0
29
+ - @lukekaalim/act@5.0.0
30
+ - @lukekaalim/act-recon@4.0.1
31
+ - @lukekaalim/act-backstage@3.2.1
32
+
3
33
  ## 8.0.3
4
34
 
5
35
  ### Patch 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
@@ -1,5 +1,5 @@
1
1
  import * as three from "three";
2
- import { ReadonlyRef, Ref } from "@lukekaalim/act";
2
+ import { WriteOnlyRef } from "@lukekaalim/act";
3
3
  import { createPrimitiveRegistry } from "@lukekaalim/act-backstage";
4
4
  import { setProps } from "./props";
5
5
 
@@ -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?: ReadonlyRef<null | 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.0.3",
5
+ "version": "8.2.0",
6
6
  "dependencies": {
7
- "@lukekaalim/act": "^4.3.0",
8
- "@lukekaalim/act-backstage": "^3.2.0",
9
- "@lukekaalim/act-recon": "^4.0.0",
10
- "@lukekaalim/act-web": "^5.2.0",
7
+ "@lukekaalim/act": "^5.0.0",
8
+ "@lukekaalim/act-backstage": "^4.0.0",
9
+ "@lukekaalim/act-recon": "^4.0.1",
10
+ "@lukekaalim/act-web": "^6.2.1",
11
11
  "@types/three": ">= 0.185.0"
12
12
  },
13
13
  "peerDependencies": {
package/props.ts CHANGED
@@ -37,7 +37,7 @@ export const setProps = (object: three.Object3D, props: PropsFromClass<three.Obj
37
37
  object.userData = props.userData;
38
38
 
39
39
  if (props.ref)
40
- (props.ref as any).current = object;
40
+ props.ref.set(object);
41
41
 
42
42
  if (object instanceof three.Mesh || object instanceof three.Points || object instanceof three.Line) {
43
43
  const meshProps = props as PropsFromClass<three.Mesh | three.Points | three.Line>;
@@ -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>;