Add 2 files
Browse files- README.md +7 -5
- index.html +320 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: deepsite-3d-cat-touch-controls
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: yellow
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,320 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>3D Interactive Cat</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.min.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/GLTFLoader.min.js"></script>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
overflow: hidden;
|
15 |
+
touch-action: none;
|
16 |
+
}
|
17 |
+
#container {
|
18 |
+
position: relative;
|
19 |
+
width: 100vw;
|
20 |
+
height: 100vh;
|
21 |
+
}
|
22 |
+
#loading {
|
23 |
+
position: absolute;
|
24 |
+
top: 0;
|
25 |
+
left: 0;
|
26 |
+
width: 100%;
|
27 |
+
height: 100%;
|
28 |
+
background: rgba(0,0,0,0.7);
|
29 |
+
display: flex;
|
30 |
+
flex-direction: column;
|
31 |
+
justify-content: center;
|
32 |
+
align-items: center;
|
33 |
+
color: white;
|
34 |
+
font-family: Arial, sans-serif;
|
35 |
+
z-index: 100;
|
36 |
+
}
|
37 |
+
.spinner {
|
38 |
+
width: 50px;
|
39 |
+
height: 50px;
|
40 |
+
border: 5px solid rgba(255,255,255,0.3);
|
41 |
+
border-radius: 50%;
|
42 |
+
border-top-color: #fff;
|
43 |
+
animation: spin 1s ease-in-out infinite;
|
44 |
+
margin-bottom: 20px;
|
45 |
+
}
|
46 |
+
@keyframes spin {
|
47 |
+
to { transform: rotate(360deg); }
|
48 |
+
}
|
49 |
+
#instructions {
|
50 |
+
position: absolute;
|
51 |
+
bottom: 20px;
|
52 |
+
width: 100%;
|
53 |
+
text-align: center;
|
54 |
+
color: white;
|
55 |
+
font-family: Arial, sans-serif;
|
56 |
+
background: rgba(0,0,0,0.5);
|
57 |
+
padding: 10px;
|
58 |
+
box-sizing: border-box;
|
59 |
+
}
|
60 |
+
</style>
|
61 |
+
</head>
|
62 |
+
<body class="bg-gray-900">
|
63 |
+
<div id="container">
|
64 |
+
<div id="loading">
|
65 |
+
<div class="spinner"></div>
|
66 |
+
<h1 class="text-2xl font-bold mb-2">Loading 3D Cat...</h1>
|
67 |
+
<p class="text-gray-300">Please wait while we prepare your interactive feline friend</p>
|
68 |
+
</div>
|
69 |
+
<div id="instructions">
|
70 |
+
<p class="text-lg">Touch and drag to rotate the cat | Pinch to zoom</p>
|
71 |
+
<p class="text-sm text-gray-300 hidden md:block">On desktop: Click and drag to rotate | Scroll to zoom</p>
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
|
75 |
+
<script>
|
76 |
+
// Initialize Three.js scene
|
77 |
+
const container = document.getElementById('container');
|
78 |
+
const loadingScreen = document.getElementById('loading');
|
79 |
+
|
80 |
+
const scene = new THREE.Scene();
|
81 |
+
scene.background = new THREE.Color(0x333333);
|
82 |
+
|
83 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
84 |
+
camera.position.z = 5;
|
85 |
+
|
86 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
87 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
88 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
89 |
+
renderer.shadowMap.enabled = true;
|
90 |
+
container.appendChild(renderer.domElement);
|
91 |
+
|
92 |
+
// Add lights
|
93 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
94 |
+
scene.add(ambientLight);
|
95 |
+
|
96 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
97 |
+
directionalLight.position.set(1, 1, 1);
|
98 |
+
directionalLight.castShadow = true;
|
99 |
+
scene.add(directionalLight);
|
100 |
+
|
101 |
+
const directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.5);
|
102 |
+
directionalLight2.position.set(-1, -1, -1);
|
103 |
+
scene.add(directionalLight2);
|
104 |
+
|
105 |
+
// Add controls
|
106 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
107 |
+
controls.enableDamping = true;
|
108 |
+
controls.dampingFactor = 0.05;
|
109 |
+
controls.screenSpacePanning = false;
|
110 |
+
controls.maxPolarAngle = Math.PI;
|
111 |
+
controls.minPolarAngle = 0;
|
112 |
+
controls.minDistance = 2;
|
113 |
+
controls.maxDistance = 10;
|
114 |
+
|
115 |
+
// Create a simple cat model (since we don't have a GLTF model)
|
116 |
+
function createCat() {
|
117 |
+
const group = new THREE.Group();
|
118 |
+
|
119 |
+
// Body (ellipsoid)
|
120 |
+
const bodyGeometry = new THREE.SphereGeometry(1, 32, 32);
|
121 |
+
bodyGeometry.scale(1.5, 0.8, 0.6);
|
122 |
+
const bodyMaterial = new THREE.MeshStandardMaterial({
|
123 |
+
color: 0xaaaaaa,
|
124 |
+
roughness: 0.7,
|
125 |
+
metalness: 0.1
|
126 |
+
});
|
127 |
+
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
|
128 |
+
body.castShadow = true;
|
129 |
+
body.receiveShadow = true;
|
130 |
+
group.add(body);
|
131 |
+
|
132 |
+
// Head (sphere)
|
133 |
+
const headGeometry = new THREE.SphereGeometry(0.6, 32, 32);
|
134 |
+
const headMaterial = new THREE.MeshStandardMaterial({
|
135 |
+
color: 0xaaaaaa,
|
136 |
+
roughness: 0.7,
|
137 |
+
metalness: 0.1
|
138 |
+
});
|
139 |
+
const head = new THREE.Mesh(headGeometry, headMaterial);
|
140 |
+
head.position.set(1.2, 0.2, 0);
|
141 |
+
head.castShadow = true;
|
142 |
+
group.add(head);
|
143 |
+
|
144 |
+
// Ears
|
145 |
+
const earGeometry = new THREE.ConeGeometry(0.3, 0.5, 32);
|
146 |
+
earGeometry.rotateX(Math.PI / 2);
|
147 |
+
|
148 |
+
const leftEar = new THREE.Mesh(earGeometry, headMaterial);
|
149 |
+
leftEar.position.set(1.5, 0.5, 0.3);
|
150 |
+
leftEar.rotation.z = -0.5;
|
151 |
+
group.add(leftEar);
|
152 |
+
|
153 |
+
const rightEar = new THREE.Mesh(earGeometry, headMaterial);
|
154 |
+
rightEar.position.set(1.5, 0.5, -0.3);
|
155 |
+
rightEar.rotation.z = 0.5;
|
156 |
+
group.add(rightEar);
|
157 |
+
|
158 |
+
// Eyes
|
159 |
+
const eyeGeometry = new THREE.SphereGeometry(0.1, 16, 16);
|
160 |
+
const eyeMaterial = new THREE.MeshStandardMaterial({ color: 0x111111 });
|
161 |
+
|
162 |
+
const leftEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
|
163 |
+
leftEye.position.set(1.6, 0.2, 0.2);
|
164 |
+
group.add(leftEye);
|
165 |
+
|
166 |
+
const rightEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
|
167 |
+
rightEye.position.set(1.6, 0.2, -0.2);
|
168 |
+
group.add(rightEye);
|
169 |
+
|
170 |
+
// Nose
|
171 |
+
const noseGeometry = new THREE.ConeGeometry(0.08, 0.2, 32);
|
172 |
+
noseGeometry.rotateX(Math.PI / 2);
|
173 |
+
const noseMaterial = new THREE.MeshStandardMaterial({ color: 0xff9999 });
|
174 |
+
const nose = new THREE.Mesh(noseGeometry, noseMaterial);
|
175 |
+
nose.position.set(1.7, 0.1, 0);
|
176 |
+
group.add(nose);
|
177 |
+
|
178 |
+
// Whiskers
|
179 |
+
const whiskerMaterial = new THREE.LineBasicMaterial({ color: 0xffffff });
|
180 |
+
|
181 |
+
// Left whiskers
|
182 |
+
const leftWhisker1 = new THREE.Line(
|
183 |
+
new THREE.BufferGeometry().setFromPoints([
|
184 |
+
new THREE.Vector3(1.6, 0.1, 0.2),
|
185 |
+
new THREE.Vector3(1.8, 0.15, 0.4)
|
186 |
+
]),
|
187 |
+
whiskerMaterial
|
188 |
+
);
|
189 |
+
group.add(leftWhisker1);
|
190 |
+
|
191 |
+
const leftWhisker2 = new THREE.Line(
|
192 |
+
new THREE.BufferGeometry().setFromPoints([
|
193 |
+
new THREE.Vector3(1.6, 0.1, 0.2),
|
194 |
+
new THREE.Vector3(1.8, 0.1, 0.4)
|
195 |
+
]),
|
196 |
+
whiskerMaterial
|
197 |
+
);
|
198 |
+
group.add(leftWhisker2);
|
199 |
+
|
200 |
+
const leftWhisker3 = new THREE.Line(
|
201 |
+
new THREE.BufferGeometry().setFromPoints([
|
202 |
+
new THREE.Vector3(1.6, 0.1, 0.2),
|
203 |
+
new THREE.Vector3(1.8, 0.05, 0.4)
|
204 |
+
]),
|
205 |
+
whiskerMaterial
|
206 |
+
);
|
207 |
+
group.add(leftWhisker3);
|
208 |
+
|
209 |
+
// Right whiskers
|
210 |
+
const rightWhisker1 = new THREE.Line(
|
211 |
+
new THREE.BufferGeometry().setFromPoints([
|
212 |
+
new THREE.Vector3(1.6, 0.1, -0.2),
|
213 |
+
new THREE.Vector3(1.8, 0.15, -0.4)
|
214 |
+
]),
|
215 |
+
whiskerMaterial
|
216 |
+
);
|
217 |
+
group.add(rightWhisker1);
|
218 |
+
|
219 |
+
const rightWhisker2 = new THREE.Line(
|
220 |
+
new THREE.BufferGeometry().setFromPoints([
|
221 |
+
new THREE.Vector3(1.6, 0.1, -0.2),
|
222 |
+
new THREE.Vector3(1.8, 0.1, -0.4)
|
223 |
+
]),
|
224 |
+
whiskerMaterial
|
225 |
+
);
|
226 |
+
group.add(rightWhisker2);
|
227 |
+
|
228 |
+
const rightWhisker3 = new THREE.Line(
|
229 |
+
new THREE.BufferGeometry().setFromPoints([
|
230 |
+
new THREE.Vector3(1.6, 0.1, -0.2),
|
231 |
+
new THREE.Vector3(1.8, 0.05, -0.4)
|
232 |
+
]),
|
233 |
+
whiskerMaterial
|
234 |
+
);
|
235 |
+
group.add(rightWhisker3);
|
236 |
+
|
237 |
+
// Legs
|
238 |
+
const legGeometry = new THREE.CylinderGeometry(0.15, 0.15, 0.5, 32);
|
239 |
+
const legMaterial = new THREE.MeshStandardMaterial({ color: 0xaaaaaa });
|
240 |
+
|
241 |
+
// Front legs
|
242 |
+
const frontLeftLeg = new THREE.Mesh(legGeometry, legMaterial);
|
243 |
+
frontLeftLeg.position.set(0.5, -0.5, 0.4);
|
244 |
+
frontLeftLeg.rotation.x = Math.PI / 2;
|
245 |
+
group.add(frontLeftLeg);
|
246 |
+
|
247 |
+
const frontRightLeg = new THREE.Mesh(legGeometry, legMaterial);
|
248 |
+
frontRightLeg.position.set(0.5, -0.5, -0.4);
|
249 |
+
frontRightLeg.rotation.x = Math.PI / 2;
|
250 |
+
group.add(frontRightLeg);
|
251 |
+
|
252 |
+
// Back legs
|
253 |
+
const backLeftLeg = new THREE.Mesh(legGeometry, legMaterial);
|
254 |
+
backLeftLeg.position.set(-0.5, -0.5, 0.4);
|
255 |
+
backLeftLeg.rotation.x = Math.PI / 2;
|
256 |
+
group.add(backLeftLeg);
|
257 |
+
|
258 |
+
const backRightLeg = new THREE.Mesh(legGeometry, legMaterial);
|
259 |
+
backRightLeg.position.set(-0.5, -0.5, -0.4);
|
260 |
+
backRightLeg.rotation.x = Math.PI / 2;
|
261 |
+
group.add(backRightLeg);
|
262 |
+
|
263 |
+
// Tail
|
264 |
+
const tailCurve = new THREE.CatmullRomCurve3([
|
265 |
+
new THREE.Vector3(-1.2, -0.3, 0),
|
266 |
+
new THREE.Vector3(-1.8, -0.2, 0),
|
267 |
+
new THREE.Vector3(-2.2, 0, 0),
|
268 |
+
new THREE.Vector3(-2.4, 0.3, 0)
|
269 |
+
]);
|
270 |
+
|
271 |
+
const tailGeometry = new THREE.TubeGeometry(tailCurve, 64, 0.1, 16, false);
|
272 |
+
const tail = new THREE.Mesh(tailGeometry, bodyMaterial);
|
273 |
+
group.add(tail);
|
274 |
+
|
275 |
+
return group;
|
276 |
+
}
|
277 |
+
|
278 |
+
// Create and add cat to scene
|
279 |
+
const cat = createCat();
|
280 |
+
scene.add(cat);
|
281 |
+
|
282 |
+
// Add floor
|
283 |
+
const floorGeometry = new THREE.PlaneGeometry(20, 20);
|
284 |
+
const floorMaterial = new THREE.MeshStandardMaterial({
|
285 |
+
color: 0x666666,
|
286 |
+
roughness: 0.8,
|
287 |
+
metalness: 0.2
|
288 |
+
});
|
289 |
+
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
|
290 |
+
floor.rotation.x = -Math.PI / 2;
|
291 |
+
floor.position.y = -0.8;
|
292 |
+
floor.receiveShadow = true;
|
293 |
+
scene.add(floor);
|
294 |
+
|
295 |
+
// Hide loading screen after a short delay (simulating loading)
|
296 |
+
setTimeout(() => {
|
297 |
+
loadingScreen.style.opacity = 0;
|
298 |
+
setTimeout(() => {
|
299 |
+
loadingScreen.style.display = 'none';
|
300 |
+
}, 500);
|
301 |
+
}, 1500);
|
302 |
+
|
303 |
+
// Handle window resize
|
304 |
+
window.addEventListener('resize', () => {
|
305 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
306 |
+
camera.updateProjectionMatrix();
|
307 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
308 |
+
});
|
309 |
+
|
310 |
+
// Animation loop
|
311 |
+
function animate() {
|
312 |
+
requestAnimationFrame(animate);
|
313 |
+
controls.update();
|
314 |
+
renderer.render(scene, camera);
|
315 |
+
}
|
316 |
+
|
317 |
+
animate();
|
318 |
+
</script>
|
319 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Broshy/deepsite-3d-cat-touch-controls" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
320 |
+
</html>
|