threedviewer 0.0.0 → 0.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/README.md +86 -0
- package/dist/FloorAligner.d.ts +10 -0
- package/dist/Resizer.d.ts +5 -0
- package/dist/SimpleViewer.d.ts +1 -4
- package/dist/ThreeSceneSetup/HexGrid/HexGrid.d.ts +10 -0
- package/dist/ThreeSceneSetup/HexGrid/HexTile.d.ts +8 -0
- package/dist/ThreeSceneSetup/addHelpers.d.ts +3 -0
- package/dist/ThreeSceneSetup/addLighting.d.ts +3 -0
- package/dist/ThreeSceneSetup/cleanupScene.d.ts +3 -0
- package/dist/ThreeSceneSetup/constants.d.ts +3 -0
- package/dist/ThreeSceneSetup/fitCameraToObject.d.ts +2 -0
- package/dist/ThreeSceneSetup/initializeCamera.d.ts +3 -0
- package/dist/ThreeSceneSetup/initializeRenderer.d.ts +3 -0
- package/dist/ThreeSceneSetup/initializeScene.d.ts +3 -0
- package/dist/ThreeSceneSetup/setupScene.d.ts +10 -0
- package/dist/ThreeSceneSetup/types.d.ts +8 -0
- package/dist/ThreeSceneSetup/updateSize.d.ts +3 -0
- package/dist/defaultOptions.d.ts +3 -0
- package/dist/index.d.ts +3 -1
- package/dist/loadModel.d.ts +3 -0
- package/dist/simple-viewer.es.js +790 -603
- package/dist/simple-viewer.umd.js +10 -10
- package/dist/types.d.ts +93 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/simpleViewerUtils.d.ts +0 -23
package/README.md
CHANGED
|
@@ -57,6 +57,92 @@ The main component for displaying 3D objects.
|
|
|
57
57
|
|
|
58
58
|
Props:
|
|
59
59
|
- `object` (required): A Three.js Object3D to be displayed in the viewer.
|
|
60
|
+
- `options` (optional): An object containing viewer options (see below).
|
|
61
|
+
|
|
62
|
+
## Configuration Options
|
|
63
|
+
|
|
64
|
+
SimpleViewer accepts an `options` prop for customization. Here's an overview of available options:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const defaultOptions = {
|
|
68
|
+
backgroundColor: '#f0f0f7',
|
|
69
|
+
camera: {
|
|
70
|
+
position: [6, 2, 1.2],
|
|
71
|
+
target: [0, 0, 0],
|
|
72
|
+
fov: 75,
|
|
73
|
+
near: 0.1,
|
|
74
|
+
far: 100000
|
|
75
|
+
},
|
|
76
|
+
lights: {
|
|
77
|
+
ambient: { color: '#404040', intensity: 1 },
|
|
78
|
+
hemisphere: {
|
|
79
|
+
skyColor: '#ffffbb',
|
|
80
|
+
groundColor: '#080820',
|
|
81
|
+
intensity: 1
|
|
82
|
+
},
|
|
83
|
+
directional: {
|
|
84
|
+
color: '#ffffff',
|
|
85
|
+
intensity: 1,
|
|
86
|
+
position: [6, 6, 6],
|
|
87
|
+
castShadow: true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
controls: {
|
|
91
|
+
enableDamping: true,
|
|
92
|
+
dampingFactor: 0.25,
|
|
93
|
+
enableZoom: true,
|
|
94
|
+
enableRotate: true,
|
|
95
|
+
enablePan: true
|
|
96
|
+
},
|
|
97
|
+
helpers: {
|
|
98
|
+
grid: true,
|
|
99
|
+
axes: false,
|
|
100
|
+
boundingBox: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
To use custom options:
|
|
106
|
+
|
|
107
|
+
```jsx
|
|
108
|
+
import React from 'react';
|
|
109
|
+
import { SimpleViewer, defaultOptions } from 'threedviewer';
|
|
110
|
+
import * as THREE from 'three';
|
|
111
|
+
|
|
112
|
+
function App() {
|
|
113
|
+
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
|
114
|
+
const material = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
|
|
115
|
+
const cube = new THREE.Mesh(geometry, material);
|
|
116
|
+
|
|
117
|
+
const customOptions = {
|
|
118
|
+
...defaultOptions,
|
|
119
|
+
backgroundColor: '#000000',
|
|
120
|
+
camera: {
|
|
121
|
+
...defaultOptions.camera,
|
|
122
|
+
cameraPosition: [12 * 6, 12 * 6, 12 * 6],
|
|
123
|
+
cameraTarget: [0, 0, 0],
|
|
124
|
+
fov: 60,
|
|
125
|
+
autoFitToObject: false,
|
|
126
|
+
},
|
|
127
|
+
lights: {
|
|
128
|
+
ambient: { intensity: 0.5 },
|
|
129
|
+
directional: { position: [10, 10, 5] }
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div style={{ width: '100%', height: '400px' }}>
|
|
135
|
+
<SimpleViewer object={cube} options={customOptions} />
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default App;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This example demonstrates how to override specific options while leaving others at their default values. You only need to specify the options you want to change.
|
|
144
|
+
|
|
145
|
+
For detailed explanations of each option, please refer to our [API documentation](link-to-api-docs).
|
|
60
146
|
|
|
61
147
|
## Development
|
|
62
148
|
|
package/dist/SimpleViewer.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import
|
|
3
|
-
interface SimpleViewerProps {
|
|
4
|
-
object: THREE.Object3D | null;
|
|
5
|
-
}
|
|
2
|
+
import { SimpleViewerProps } from './types';
|
|
6
3
|
declare const SimpleViewer: React.FC<SimpleViewerProps>;
|
|
7
4
|
export default SimpleViewer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as HexTile } from './HexTile';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
declare class HexGrid {
|
|
4
|
+
radius: number;
|
|
5
|
+
tileSize: number;
|
|
6
|
+
constructor(radius: number, tileSize: number);
|
|
7
|
+
generateGrid(): HexTile[];
|
|
8
|
+
addToScene(scene: THREE.Scene): void;
|
|
9
|
+
}
|
|
10
|
+
export default HexGrid;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
2
|
+
import { THREEBase } from './types';
|
|
3
|
+
import { SimpleViewerOptions } from '../types';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
export declare const setupScene: (threeBase: THREEBase, object: THREE.Object3D | null, options: SimpleViewerOptions) => {
|
|
6
|
+
scene: THREE.Scene;
|
|
7
|
+
camera: THREE.PerspectiveCamera;
|
|
8
|
+
renderer: THREE.WebGLRenderer;
|
|
9
|
+
controls: OrbitControls;
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
export type THREEBase = {
|
|
4
|
+
mountRef: React.RefObject<HTMLDivElement>;
|
|
5
|
+
rendererRef: React.MutableRefObject<THREE.WebGLRenderer | null>;
|
|
6
|
+
cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;
|
|
7
|
+
sceneRef: React.MutableRefObject<THREE.Scene | null>;
|
|
8
|
+
};
|
package/dist/index.d.ts
CHANGED