@lukekaalim/act-three 5.3.0 → 5.5.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/hooks.js +15 -4
- package/package.json +3 -3
package/hooks.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
/*:: import type { Ref } from '@lukekaalim/act'; */
|
|
3
|
-
/*:: import type {
|
|
3
|
+
/*:: import type {
|
|
4
|
+
Camera,
|
|
5
|
+
Scene,
|
|
6
|
+
Texture,
|
|
7
|
+
Object3D,
|
|
8
|
+
PerspectiveCamera,
|
|
9
|
+
OrthographicCamera,
|
|
10
|
+
} from "three"; */
|
|
4
11
|
import { TextureLoader, Vector2, WebGLRenderer } from "three";
|
|
5
12
|
|
|
6
13
|
import { useEffect, useState } from "@lukekaalim/act";
|
|
@@ -49,11 +56,13 @@ export const useWebGLRenderer = (
|
|
|
49
56
|
// like: width: 100%
|
|
50
57
|
export const useResizingRenderer = (
|
|
51
58
|
canvasRef/*: Ref<?HTMLCanvasElement>*/,
|
|
52
|
-
renderer/*: ?WebGLRenderer
|
|
59
|
+
renderer/*: ?WebGLRenderer*/,
|
|
60
|
+
cameraRef/*: ?Ref<?PerspectiveCamera>*/ = null,
|
|
53
61
|
)/*: ?Vector2*/ => {
|
|
54
62
|
const [size, setSize] = useState(null)
|
|
55
63
|
useEffect(() => {
|
|
56
64
|
const { current: canvas } = canvasRef;
|
|
65
|
+
const { current: camera } = (cameraRef || { current: null })
|
|
57
66
|
if (!canvas || !renderer)
|
|
58
67
|
return null;
|
|
59
68
|
|
|
@@ -64,6 +73,10 @@ export const useResizingRenderer = (
|
|
|
64
73
|
const size = new Vector2(width, height);
|
|
65
74
|
setSize(size);
|
|
66
75
|
renderer.setSize(width, height, false);
|
|
76
|
+
if (camera) {
|
|
77
|
+
camera.aspect = width / height;
|
|
78
|
+
camera.updateProjectionMatrix();
|
|
79
|
+
}
|
|
67
80
|
}
|
|
68
81
|
});
|
|
69
82
|
observer.observe(canvas, { box: 'content-box' });
|
|
@@ -159,8 +172,6 @@ export const useTexture = (url/*: string*/)/*: Texture*/ => {
|
|
|
159
172
|
|
|
160
173
|
const texture = loader.load(url);
|
|
161
174
|
setTexture(texture);
|
|
162
|
-
|
|
163
|
-
console.log(loader);
|
|
164
175
|
|
|
165
176
|
return () => {
|
|
166
177
|
texture.dispose();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukekaalim/act-three",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Render threejs content using act",
|
|
5
5
|
"main": "entry.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"author": "Luke Kaalim",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"three": "^0.
|
|
15
|
+
"three": "^0.141.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@lukekaalim/act": "^2.2.0",
|
|
19
|
-
"@lukekaalim/act-renderer-core": "^3.
|
|
19
|
+
"@lukekaalim/act-renderer-core": "^3.2.0",
|
|
20
20
|
"@lukekaalim/act-reconciler": "^3.0.1",
|
|
21
21
|
"@lukekaalim/act-web": "^1.2.0"
|
|
22
22
|
}
|