react-three-game 0.0.42 → 0.0.44
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.
|
@@ -33,7 +33,7 @@ extend({
|
|
|
33
33
|
export default function GameCanvas(_a) {
|
|
34
34
|
var { loader = false, children, glConfig } = _a, props = __rest(_a, ["loader", "children", "glConfig"]);
|
|
35
35
|
const [frameloop, setFrameloop] = useState("never");
|
|
36
|
-
return _jsx(_Fragment, { children: _jsxs(Canvas, Object.assign({ style: { touchAction: 'none' }, shadows: { type: PCFShadowMap, }, frameloop: frameloop, gl: (_a) => __awaiter(this, [_a], void 0, function* ({ canvas }) {
|
|
36
|
+
return _jsx(_Fragment, { children: _jsxs(Canvas, Object.assign({ style: { touchAction: 'none', userSelect: 'none' }, shadows: { type: PCFShadowMap, }, frameloop: frameloop, gl: (_a) => __awaiter(this, [_a], void 0, function* ({ canvas }) {
|
|
37
37
|
const renderer = new WebGPURenderer(Object.assign({ canvas: canvas,
|
|
38
38
|
// @ts-expect-error futuristic
|
|
39
39
|
shadowMap: true, antialias: true }, glConfig));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Canvas, useLoader } from "@react-three/fiber";
|
|
3
|
-
import { OrbitControls,
|
|
3
|
+
import { OrbitControls, View, PerspectiveCamera } from "@react-three/drei";
|
|
4
4
|
import { Suspense, useEffect, useState, useRef } from "react";
|
|
5
5
|
import { TextureLoader } from "three";
|
|
6
6
|
import { loadModel } from "../dragdrop/modelLoader";
|
|
@@ -103,7 +103,7 @@ function ModelCard({ file, onSelect, basePath = "" }) {
|
|
|
103
103
|
if (error) {
|
|
104
104
|
return (_jsx("div", { ref: ref, style: { aspectRatio: '1 / 1', backgroundColor: '#374151', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center' }, onClick: () => onSelect(file), children: _jsx("div", { style: styles.errorIcon, children: "\u2717" }) }));
|
|
105
105
|
}
|
|
106
|
-
return (_jsxs("div", { ref: ref, style: { maxWidth: 60, aspectRatio: '1 / 1', backgroundColor: '#111827', cursor: 'pointer', display: 'flex', flexDirection: 'column' }, onClick: () => onSelect(file), children: [_jsx("div", { style: styles.flexFillRelative, children: isInView ? (_jsxs(View, { style: { width: '100%', height: '100%' }, children: [_jsx(PerspectiveCamera, { makeDefault: true, position: [0, 1, 3], fov: 50 }), _jsxs(Suspense, { fallback: null, children: [_jsx(
|
|
106
|
+
return (_jsxs("div", { ref: ref, style: { maxWidth: 60, aspectRatio: '1 / 1', backgroundColor: '#111827', cursor: 'pointer', display: 'flex', flexDirection: 'column' }, onClick: () => onSelect(file), children: [_jsx("div", { style: styles.flexFillRelative, children: isInView ? (_jsxs(View, { style: { width: '100%', height: '100%' }, children: [_jsx(PerspectiveCamera, { makeDefault: true, position: [0, 1, 3], fov: 50 }), _jsxs(Suspense, { fallback: null, children: [_jsx(ModelPreview, { url: fullPath, onError: () => setError(true) }), _jsx(OrbitControls, { enableZoom: false })] })] })) : null }), _jsx("div", { style: { backgroundColor: 'rgba(0,0,0,0.6)', fontSize: 10, padding: '0 4px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', textAlign: 'center' }, children: file.split('/').pop() })] }));
|
|
107
107
|
}
|
|
108
108
|
function ModelPreview({ url, onError }) {
|
|
109
109
|
const [model, setModel] = useState(null);
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ export default function GameCanvas({ loader = false, children, glConfig, ...prop
|
|
|
24
24
|
|
|
25
25
|
return <>
|
|
26
26
|
<Canvas
|
|
27
|
-
style={{ touchAction: 'none' }}
|
|
27
|
+
style={{ touchAction: 'none', userSelect: 'none' }}
|
|
28
28
|
shadows={{ type: PCFShadowMap, }}
|
|
29
29
|
frameloop={frameloop}
|
|
30
30
|
gl={async ({ canvas }) => {
|
|
@@ -269,9 +269,7 @@ function ModelCard({ file, onSelect, basePath = "" }: { file: string; onSelect:
|
|
|
269
269
|
<View style={{ width: '100%', height: '100%' }}>
|
|
270
270
|
<PerspectiveCamera makeDefault position={[0, 1, 3]} fov={50} />
|
|
271
271
|
<Suspense fallback={null}>
|
|
272
|
-
<
|
|
273
|
-
<ModelPreview url={fullPath} onError={() => setError(true)} />
|
|
274
|
-
</Stage>
|
|
272
|
+
<ModelPreview url={fullPath} onError={() => setError(true)} />
|
|
275
273
|
<OrbitControls enableZoom={false} />
|
|
276
274
|
</Suspense>
|
|
277
275
|
</View>
|