@lukekaalim/act-three 3.2.0 → 3.3.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/components.js CHANGED
@@ -6,6 +6,7 @@
6
6
  Quaternion,
7
7
  BufferGeometry,
8
8
  Material,
9
+ Texture,
9
10
  } from "three"; */
10
11
  /*:: import * as Three from 'three'; */
11
12
 
@@ -44,6 +45,8 @@ export type ThreeProps = {
44
45
  width: number,
45
46
  height: number,
46
47
  setStyle?: boolean,
48
+ background?: string | null | Texture,
49
+ alpha?: boolean,
47
50
  };
48
51
  */
49
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukekaalim/act-three",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Render threejs content using act",
5
5
  "main": "main.js",
6
6
  "type": "module",
package/render.js CHANGED
@@ -19,11 +19,12 @@ export const createThreeRenderer = (nodeDefs/*: NodeDefinition[]*/ = threeNodes)
19
19
  const objects = new Map();
20
20
 
21
21
  const createRoot = (diff) => {
22
- const renderer = new WebGLRenderer();
23
- const { width, height, setStyle = false } = (diff.next.element.props/*: any*/);
22
+ const { width, height, setStyle = false, background = null, alpha = false } = (diff.next.element.props/*: any*/);
24
23
 
24
+ const renderer = new WebGLRenderer({ alpha });
25
25
  renderer.setSize(width, height, setStyle);
26
26
  const scene = new Scene();
27
+ scene.background = background;
27
28
  const camera = new PerspectiveCamera( 75, width / height, 0.1, 1000 );
28
29
  camera.position.z = 5;
29
30
 
@@ -38,13 +39,15 @@ export const createThreeRenderer = (nodeDefs/*: NodeDefinition[]*/ = threeNodes)
38
39
  };
39
40
  const setRootProps = (diff, [renderer, scene, camera]) => {
40
41
  const props = calculatePropsDiff(diff.prev.element.props, diff.next.element.props);
42
+ const { width, height, setStyle = false, background = null, alpha = false } = (diff.next.element.props/*: any*/);
41
43
 
42
44
  if (props.has('width') || props.has('height') || props.has('setStyle')) {
43
- const { width, height, setStyle = false } = (diff.next.element.props/*: any*/);
44
45
  renderer.setSize(width, height, setStyle);
45
46
  camera.aspect = width / height;
46
47
  camera.updateProjectionMatrix();
47
48
  }
49
+ if (props.has('background'))
50
+ scene.background = background;
48
51
  }
49
52
 
50
53
  const removeRenderer = (diff, [renderer, scene, camera]) => {