-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgb3.html
More file actions
85 lines (62 loc) · 2.52 KB
/
gb3.html
File metadata and controls
85 lines (62 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Babylon Template</title>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
<script src="babylon.max.js"></script>
<script src="babylon.gui.js"></script>
</head>
<body>
<canvas id="renderCanvas" touch-action="none"></canvas> <!-- touch-action="none" for best results from PEP -->
<script>
const canvas = document.getElementById("renderCanvas"); // Get the canvas element
const engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
// Add your code here matching the playground format
const createScene = function () {
const scene = new BABYLON.Scene(engine);
const light = new BABYLON.HemisphericLight("HemiLight", new BABYLON.Vector3(0, 1, 0), scene);
const camera = new BABYLON.ArcRotateCamera("camera1", -Math.PI / 2, Math.PI / 2.2, 5, new BABYLON.Vector3(0, 0, 0), scene);
camera.attachControl(canvas, true);
let m = 5;
let n = 2;
const goldberg = BABYLON.MeshBuilder.CreateGoldberg("g", {m: m, n: n});
let colors = [];
let face = 0;
colors.push([face, face, new BABYLON.Color4(1, 0, 0, 1)]);
for (f = 0; f < goldberg.goldbergData.adjacentFaces[face].length; f++) {
colors.push([goldberg.goldbergData.adjacentFaces[face][f], goldberg.goldbergData.adjacentFaces[face][f], new BABYLON.Color4(0, 0, 1, 1)]);
}
face = 85;
colors.push([face, face, new BABYLON.Color4(1, 0, 1, 1)]);
for (f = 0; f < goldberg.goldbergData.adjacentFaces[face].length; f++) {
colors.push([goldberg.goldbergData.adjacentFaces[face][f], goldberg.goldbergData.adjacentFaces[face][f], new BABYLON.Color4(0, 1, 0)]);
}
goldberg.setGoldbergFaceColors(colors);
return scene;
};
const scene = createScene(); //Call the createScene function
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function () {
scene.render();
});
// Watch for browser/canvas resize events
window.addEventListener("resize", function () {
engine.resize();
});
</script>
</body>
</html>