Reaperxxxx commited on
Commit
436d005
·
verified ·
1 Parent(s): 8e9e979

Update view.html

Browse files
Files changed (1) hide show
  1. view.html +84 -99
view.html CHANGED
@@ -1,118 +1,103 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <title>Character Bone Viewer</title>
6
- <style>
7
- body {
8
- margin: 0;
9
- overflow: hidden;
10
- background: #111;
11
- color: #0f0;
12
- font-family: monospace;
13
- }
14
- #boneList {
15
- position: fixed;
16
- top: 10px;
17
- left: 10px;
18
- max-height: 95vh;
19
- width: 300px;
20
- overflow-y: auto;
21
- background: rgba(0, 0, 0, 0.5);
22
- padding: 10px;
23
- border: 1px solid #0f0;
24
- border-radius: 4px;
25
- }
26
- #boneList h2 {
27
- margin-top: 0;
28
- color: #0ff;
29
- }
30
- #boneList ul {
31
- padding-left: 20px;
32
- }
33
- </style>
34
 
35
- <script type="importmap">
36
- {
37
- "imports": {
38
- "three": "https://cdn.jsdelivr.net/npm/three@0.128.0/build/three.module.js",
39
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.128.0/examples/jsm/"
40
- }
41
- }
42
- </script>
43
- </head>
44
- <body>
45
- <div id="boneList">
46
- <h2>🦴 Bones</h2>
47
- <ul id="bones"></ul>
48
- </div>
49
 
50
- <script type="module">
51
- import * as THREE from 'three';
52
- import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
 
53
 
54
- let scene, camera, renderer, character;
55
 
56
- init();
57
- animate();
58
 
59
- function init() {
60
- scene = new THREE.Scene();
61
- scene.background = new THREE.Color(0x1a1a2e);
 
 
 
62
 
63
- camera = new THREE.PerspectiveCamera(
64
- 75,
65
- window.innerWidth / window.innerHeight,
66
- 0.1,
67
- 50
68
- );
69
- camera.position.set(0, 1.5, 3);
70
 
71
- renderer = new THREE.WebGLRenderer({ antialias: true });
72
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
73
- renderer.setSize(window.innerWidth, window.innerHeight);
74
- document.body.appendChild(renderer.domElement);
75
-
76
- // Lighting
77
- const light = new THREE.DirectionalLight(0xffffff, 1);
78
- light.position.set(2, 3, 4);
79
- scene.add(light);
80
- scene.add(new THREE.AmbientLight(0xffffff, 0.5));
81
 
82
- // Load character
83
- const loader = new GLTFLoader();
84
- loader.load('./character.glb', (gltf) => {
85
- character = gltf.scene;
86
- character.position.set(0, 0, 0);
87
- scene.add(character);
88
 
89
- // Display all bones
90
- const boneList = document.getElementById('bones');
91
- const bones = [];
92
- gltf.scene.traverse((obj) => {
93
- if (obj.isBone) bones.push(obj.name);
94
- });
95
 
96
- if (bones.length === 0) {
97
- boneList.innerHTML = '<li>No bones found.</li>';
98
- } else {
99
- boneList.innerHTML = bones.map(name => `<li>${name}</li>`).join('');
100
- }
101
- });
102
 
103
- window.addEventListener('resize', onWindowResize);
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- function onWindowResize() {
 
107
  camera.aspect = window.innerWidth / window.innerHeight;
108
  camera.updateProjectionMatrix();
109
  renderer.setSize(window.innerWidth, window.innerHeight);
110
- }
 
111
 
112
- function animate() {
113
- requestAnimationFrame(animate);
114
- renderer.render(scene, camera);
115
- }
116
- </script>
117
- </body>
 
 
118
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Character Viewer</title>
6
+ <style>
7
+ body { margin: 0; overflow: hidden; background: #000; }
8
+ canvas { display: block; }
9
+ #loading {
10
+ position: fixed;
11
+ top: 50%; left: 50%;
12
+ transform: translate(-50%, -50%);
13
+ color: white;
14
+ background: rgba(0,0,0,0.7);
15
+ padding: 20px 30px;
16
+ border-radius: 10px;
17
+ font-family: sans-serif;
18
+ }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <div id="loading">Loading character...</div>
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ <script type="importmap">
25
+ {
26
+ "imports": {
27
+ "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
28
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
29
+ }
30
+ }
31
+ </script>
 
 
 
 
 
 
32
 
33
+ <script type="module">
34
+ import * as THREE from 'three';
35
+ import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
36
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
37
 
38
+ let scene, camera, renderer, controls, model;
39
 
40
+ init();
41
+ animate();
42
 
43
+ function init() {
44
+ // Scene and Camera
45
+ scene = new THREE.Scene();
46
+ scene.background = new THREE.Color(0x111111);
47
+ camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
48
+ camera.position.set(0, 1.5, 3);
49
 
50
+ // Renderer
51
+ renderer = new THREE.WebGLRenderer({ antialias: true });
52
+ renderer.setSize(window.innerWidth, window.innerHeight);
53
+ renderer.outputEncoding = THREE.sRGBEncoding;
54
+ document.body.appendChild(renderer.domElement);
 
 
55
 
56
+ // Lighting
57
+ scene.add(new THREE.AmbientLight(0xffffff, 0.5));
 
 
 
 
 
 
 
 
58
 
59
+ const dirLight = new THREE.DirectionalLight(0xffffff, 1);
60
+ dirLight.position.set(2, 4, 2);
61
+ dirLight.castShadow = true;
62
+ scene.add(dirLight);
 
 
63
 
64
+ const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.4);
65
+ hemiLight.position.set(0, 10, 0);
66
+ scene.add(hemiLight);
 
 
 
67
 
68
+ // Controls
69
+ controls = new OrbitControls(camera, renderer.domElement);
70
+ controls.enableDamping = true;
 
 
 
71
 
72
+ // Load FBX Model
73
+ const loader = new FBXLoader();
74
+ loader.load('./character.fbx', (fbx) => {
75
+ model = fbx;
76
+ model.scale.set(0.01, 0.01, 0.01); // adjust size as needed
77
+ scene.add(model);
78
+ document.getElementById('loading').style.display = 'none';
79
+ }, (xhr) => {
80
+ const percent = (xhr.loaded / xhr.total * 100).toFixed(1);
81
+ document.getElementById('loading').textContent = `Loading ${percent}%`;
82
+ }, (error) => {
83
+ document.getElementById('loading').textContent = 'Error loading character.fbx';
84
+ console.error(error);
85
+ });
86
 
87
+ // Responsive resize
88
+ window.addEventListener('resize', () => {
89
  camera.aspect = window.innerWidth / window.innerHeight;
90
  camera.updateProjectionMatrix();
91
  renderer.setSize(window.innerWidth, window.innerHeight);
92
+ });
93
+ }
94
 
95
+ function animate() {
96
+ requestAnimationFrame(animate);
97
+ if (model) model.rotation.y += 0.005; // slowly rotate the model
98
+ controls.update();
99
+ renderer.render(scene, camera);
100
+ }
101
+ </script>
102
+ </body>
103
  </html>