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 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
 
@@ -0,0 +1,10 @@
1
+ import * as THREE from 'three';
2
+ declare class FloorAligner {
3
+ private object;
4
+ private boundingBox;
5
+ constructor(object: THREE.Object3D);
6
+ alignToFloor(): void;
7
+ private calculateFloorOffset;
8
+ private applyOffset;
9
+ }
10
+ export default FloorAligner;
@@ -0,0 +1,5 @@
1
+ import * as THREE from 'three';
2
+ declare class Resizer {
3
+ resize(object: THREE.Object3D, targetSize: THREE.Vector3): void;
4
+ }
5
+ export default Resizer;
@@ -1,7 +1,4 @@
1
1
  import { default as React } from 'react';
2
- import * as THREE from 'three';
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,8 @@
1
+ import * as THREE from 'three';
2
+ declare class HexTile {
3
+ position: THREE.Vector3;
4
+ size: number;
5
+ constructor(position: THREE.Vector3, size: number);
6
+ createMesh(): THREE.LineSegments;
7
+ }
8
+ export default HexTile;
@@ -0,0 +1,3 @@
1
+ import { HelperOptions } from '../types';
2
+ import * as THREE from 'three';
3
+ export declare const addHelpers: (scene: THREE.Scene, object: THREE.Object3D | null, options: HelperOptions) => void;
@@ -0,0 +1,3 @@
1
+ import { LightningOptions } from '../types';
2
+ import * as THREE from 'three';
3
+ export declare const addLighting: (scene: THREE.Scene, options: LightningOptions) => void;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ import * as THREE from 'three';
3
+ export declare const cleanupScene: (mountRef: React.RefObject<HTMLDivElement>, renderer: THREE.WebGLRenderer, resizeHandler: () => void) => void;
@@ -0,0 +1,3 @@
1
+ export declare const BACKGROUND_COLOR = 15790327;
2
+ export declare const UNITS_PER_INCH = 1;
3
+ export declare const UNITS_PER_FOOT: number;
@@ -0,0 +1,2 @@
1
+ import * as THREE from 'three';
2
+ export declare const fitCameraToObject: (scene: THREE.Scene, camera: THREE.PerspectiveCamera) => void;
@@ -0,0 +1,3 @@
1
+ import { CameraOptions } from '../types';
2
+ import * as THREE from 'three';
3
+ export declare const initializeCamera: (aspectRatio: number, cameraOptions: CameraOptions) => THREE.PerspectiveCamera;
@@ -0,0 +1,3 @@
1
+ import { RendererOptions } from '../types';
2
+ import * as THREE from 'three';
3
+ export declare const initializeRenderer: (rendererOptions: RendererOptions) => THREE.WebGLRenderer;
@@ -0,0 +1,3 @@
1
+ import { SimpleViewerOptions } from '../types';
2
+ import * as THREE from 'three';
3
+ export declare const initializeScene: (options: SimpleViewerOptions) => THREE.Scene;
@@ -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
+ };
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ import * as THREE from 'three';
3
+ export declare const updateSize: (renderer: THREE.WebGLRenderer, camera: THREE.PerspectiveCamera, mountRef: React.RefObject<HTMLDivElement>, scene: THREE.Scene) => void;
@@ -0,0 +1,3 @@
1
+ import { SimpleViewerOptions } from './types';
2
+ declare const defaultOptions: SimpleViewerOptions;
3
+ export default defaultOptions;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default as SimpleViewer } from './SimpleViewer';
2
- export * from './simpleViewerUtils';
2
+ export { type SimpleViewerProps } from './types';
3
+ export { type SimpleViewerOptions } from './types';
4
+ export { default as defaultOptions } from './defaultOptions';
@@ -0,0 +1,3 @@
1
+ import { LoaderGLB } from './types';
2
+ import * as THREE from 'three';
3
+ export declare const loadModel: (url: string, loader: LoaderGLB, targetSize?: THREE.Vector3) => Promise<THREE.Object3D>;