awacke1 commited on
Commit
099850b
·
1 Parent(s): 2bdaabd

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +82 -17
index.html CHANGED
@@ -1,19 +1,84 @@
1
  <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Babylon.js Game Example</title>
6
+ <script src="https://cdn.babylonjs.com/babylon.js"></script>
7
+ <script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
8
+ <style>
9
+ canvas {
10
+ width: 100%;
11
+ height: 100%;
12
+ touch-action: none;
13
+ }
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <canvas id="renderCanvas"></canvas>
18
+ <script>
19
+ window.addEventListener('DOMContentLoaded', function () {
20
+ var canvas = document.getElementById('renderCanvas');
21
+ var engine = new BABYLON.Engine(canvas, true);
22
+ var createScene = function () {
23
+ var scene = new BABYLON.Scene(engine);
24
+ // Create a camera
25
+ var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
26
+ // Create a light
27
+ var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
28
+ // Create an array to hold the spheres
29
+ var spheres = [];
30
+ // Load the texture and bump map
31
+ var texture = new BABYLON.Texture("https://www.babylonjs-playground.com/textures/floor.png", scene);
32
+ var bumpMap = new BABYLON.Texture("https://www.babylonjs-playground.com/textures/floor_n.jpg", scene);
33
+ // Create a fountain of spheres that follow the mouse
34
+ canvas.addEventListener('mousemove', function (event) {
35
+ // Create a new sphere
36
+ var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter: Math.random() * 2 + 0.5, segments: 16}, scene);
37
+ sphere.position = new BABYLON.Vector3(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2);
38
+ sphere.material = new BABYLON.StandardMaterial("texture", scene);
39
+ sphere.material.diffuseTexture = texture;
40
+ sphere.material.bumpTexture = bumpMap;
41
+ spheres.push(sphere);
42
+ // Follow the mouse with the spheres
43
+ var ray = scene.createPickingRay(event.clientX, event.clientY, BABYLON.Matrix.Identity(), camera);
44
+ var pickInfo = scene.pickWithRay(ray, function (mesh) { return mesh == sphere; });
45
+ if (pickInfo.hit) {
46
+ sphere.position.copyFrom(pickInfo.pickedPoint);
47
+ }
48
+ // Animate the texture of the spheres
49
+ var textureAnimation = new BABYLON.Animation("textureAnimation", "material.diffuseTexture.uOffset", 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
50
+ var keys = [];
51
+ keys.push({frame: 0, value: 0});
52
+ keys.push({frame: 100, value: 1});
53
+ textureAnimation.setKeys(keys);
54
+ sphere.material.diffuseTexture.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
55
+ sphere.material.diffuseTexture.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
56
+ sphere.material.diffuseTexture.uScale = 10;
57
+ sphere.material.diffuseTexture.vScale = 10;
58
+ sphere.animations.push(textureAnimation);
59
+ scene.beginAnimation(sphere, 0, 100, true);
60
+ // Animate the spheres
61
+ var animation = new BABYLON.Animation("myAnimation", "position.y", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
62
+ var keys = [];
63
+ keys.push({frame: 0, value: sphere.position.y});
64
+ keys.push({frame: 50, value: sphere.position.y + 2});
65
+ keys.push({frame: 100, value: sphere.position.y});
66
+ animation.setKeys(keys);
67
+ sphere.animations.push(animation);
68
+ scene.beginAnimation(sphere, 0, 100, true);
69
+ });
70
+
71
+ return scene;
72
+ }
73
+ var scene = createScene();
74
+ engine.runRenderLoop(function () {
75
+ scene.render();
76
+ });
77
+ window.addEventListener('resize', function () {
78
+ engine.resize();
79
+ });
80
+ });
81
+
82
+ </script>
83
+ </body>
84
+ </html>