Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
538 lines (444 loc) · 25.3 KB
/
Copy pathindex.html
File metadata and controls
538 lines (444 loc) · 25.3 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>v0.7 Scatterplot</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Babylon.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script>
<script src="./babylon/dist/ammo.js"></script>
<script src="./babylon/dist/cannon.js"></script>
<script src="./babylon/dist/Oimo.js"></script>
<script src="./babylon/dist/earcut.min.js"></script>
<script src="./babylon/dist/babylon.js"></script>
<script src="./babylon/dist/materialsLibrary/babylonjs.materials.min.js"></script>
<script src="./babylon/dist/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js"></script>
<script src="./babylon/dist/postProcessesLibrary/babylonjs.postProcess.min.js"></script>
<script src="./babylon/dist/loaders/babylonjs.loaders.js"></script>
<script src="./babylon/dist/serializers/babylonjs.serializers.min.js"></script>
<script src="./babylon/dist/gui/babylon.gui.min.js"></script>
<script src="./babylon/dist/inspector/babylon.inspector.bundle.js"></script>
<!-- links to the latest version of the minified glTF serializer -->
<!-- <script src="./js/glTF2Serializer.min.js"></script> -->
<style>
html, body {
background-color: black;
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
</head>
<body>
<canvas id="renderCanvas"></canvas>
<script>
var canvas = document.getElementById("renderCanvas");
var engine = null;
var scene = null;
var sceneToRender = null;
var createDefaultEngine = function() {
return new BABYLON.Engine(canvas, true, {
preserveDrawingBuffer: true,
stencil: true,
disableWebGL2Support: false
});
};
let W = 180,
H = 180,
D = 300;
//converted from csv to json
var inputData=[{year:2017,t1:29,t2:29,t3:28,t4:27,t5:27,t6:26,t7:26,t8:26,t9:26,t10:27,t11:29,t12:29,t13:28,t14:28,t15:29,t16:31,t17:32,t18:33,t19:34,t20:35,t21:35,t22:35,t23:36,t24:37,t25:37,t26:35,t27:35,t28:34,t29:34,t30:33,t31:31},{year:2016,t1:28,t2:28,t3:27,t4:26,t5:26,t6:25,t7:25,t8:25,t9:25,t10:26,t11:27,t12:27,t13:28,t14:28,t15:29,t16:30,t17:31,t18:32,t19:33,t20:34,t21:34,t22:35,t23:36,t24:37,t25:36,t26:34,t27:34,t28:33,t29:33,t30:32,t31:31},{year:2015,t1:27,t2:27,t3:27,t4:26,t5:25,t6:25,t7:25,t8:25,t9:25,t10:25,t11:27,t12:27,t13:27,t14:27,t15:28,t16:29,t17:30,t18:31,t19:32,t20:33,t21:33,t22:34,t23:35,t24:36,t25:35,t26:34,t27:33,t28:32,t29:32,t30:31,t31:30},{year:2014,t1:27,t2:27,t3:27,t4:26,t5:25,t6:25,t7:25,t8:25,t9:25,t10:25,t11:26,t12:26,t13:27,t14:26,t15:27,t16:28,t17:29,t18:30,t19:31,t20:32,t21:32,t22:33,t23:35,t24:35,t25:34,t26:33,t27:32,t28:31,t29:31,t30:30,t31:29},{year:2013,t1:27,t2:27,t3:27,t4:26,t5:25,t6:25,t7:25,t8:25,t9:26,t10:25,t11:27,t12:27,t13:27,t14:27,t15:28,t16:29,t17:30,t18:31,t19:32,t20:33,t21:33,t22:34,t23:35,t24:36,t25:35,t26:34,t27:33,t28:32,t29:32,t30:31,t31:30},{year:2012,t1:28,t2:28,t3:27,t4:26,t5:26,t6:25,t7:25,t8:25,t9:25,t10:26,t11:27,t12:27,t13:28,t14:28,t15:29,t16:30,t17:31,t18:32,t19:33,t20:34,t21:34,t22:35,t23:36,t24:37,t25:36,t26:34,t27:34,t28:33,t29:33,t30:32,t31:31},{year:2011,t1:29,t2:29,t3:28,t4:27,t5:27,t6:26,t7:26,t8:26,t9:26,t10:27,t11:29,t12:29,t13:28,t14:28,t15:29,t16:31,t17:32,t18:33,t19:34,t20:35,t21:35,t22:35,t23:36,t24:37,t25:37,t26:35,t27:35,t28:34,t29:34,t30:33,t31:31},{year:2010,t1:30,t2:30,t3:29,t4:28,t5:28,t6:27,t7:27,t8:27,t9:27,t10:28,t11:30,t12:30,t13:29,t14:29,t15:30,t16:31,t17:32,t18:34,t19:35,t20:36,t21:36,t22:36,t23:37,t24:36,t25:36,t26:35,t27:36,t28:34,t29:33,t30:32,t31:30},{year:2009,t1:31,t2:31,t3:30,t4:29,t5:29,t6:28,t7:28,t8:28,t9:28,t10:29,t11:31,t12:31,t13:30,t14:30,t15:31,t16:32,t17:33,t18:34,t19:35,t20:36,t21:37,t22:37,t23:37,t24:36,t25:35,t26:35,t27:34,t28:33,t29:32,t30:31,t31:29},{year:2008,t1:32,t2:32,t3:31,t4:30,t5:30,t6:29,t7:29,t8:29,t9:29,t10:30,t11:32,t12:32,t13:31,t14:31,t15:32,t16:33,t17:34,t18:35,t19:36,t20:37,t21:37,t22:37,t23:37,t24:37,t25:35,t26:35,t27:34,t28:32,t29:31,t30:30,t31:29},{year:2007,t1:32,t2:32,t3:31,t4:30,t5:30,t6:29,t7:29,t8:29,t9:29,t10:30,t11:32,t12:32,t13:31,t14:31,t15:32,t16:33,t17:34,t18:35,t19:36,t20:37,t21:37,t22:37,t23:37,t24:37,t25:35,t26:35,t27:34,t28:32,t29:31,t30:30,t31:29},{year:2006,t1:30,t2:30,t3:29,t4:28,t5:28,t6:27,t7:27,t8:27,t9:27,t10:28,t11:30,t12:30,t13:29,t14:29,t15:30,t16:31,t17:32,t18:34,t19:35,t20:36,t21:36,t22:36,t23:37,t24:36,t25:36,t26:35,t27:36,t28:34,t29:33,t30:32,t31:30}];
// var VR_mode = false;
var createScene = function() {
var scene = new BABYLON.Scene(engine);
// Background color
scene.clearColor = new BABYLON.Color4(0,0,0,1);
var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);
var camera = new BABYLON.ArcRotateCamera("Camera", 0.33, 1.33, 350, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
camera.fov = 1;
if (navigator.getVRDisplays)
var camera2 = new BABYLON.WebVRFreeCamera("camera1", new BABYLON.Vector3(0, 1, 0), scene, false, {
trackPosition: true
});
else
var camera2 = new BABYLON.VRDeviceOrientationArcRotateCamera("vrCam", 0.76, 1.41, 350, BABYLON.Vector3.Zero(), scene);
camera2.attachControl(canvas, true);
scatterPlot = new ScatterPlot([W, H, D], {
x: [50, 50, 51, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006],
y: ["", "25°", "26°", "27°", "28°", "29°", "30°", "31°", "32°", "33°", "34°", "35°", "36°", "37°", "38°", "39°", "40°"],
z: ["", 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, "09", "08", "07", "06", "05", "04", "03", "02", "01"]
}, scene);
var sp_labels = scatterPlot.labelsInfo;
//set points
var points = [];
for (var i = 0; i < inputData.length; i++) {
var x = Object.keys(sp_labels['x']).filter(function(k) {
return sp_labels['x'][k] == inputData[i]["year"];
});
var xp = sp_labels['x'].length - x[0];
var z = 1;
for (var j in inputData[i]) {
if (j == "year") continue;
var y = inputData[i][j] - 24;
points.push(new BABYLON.Vector3(roundToTwo(xp), roundToTwo(y), roundToTwo(z)));
z++;
}
}
console.log(points)
// scatterPlot.draw(points);
scatterPlot.dispose();
scatterPlot.draw(points, true);
const xr = scene.createDefaultXRExperienceAsync({
// ask for an ar-session
uiOptions: {
sessionMode: "immersive-ar",
},
optionalFeatures: true,
});
// const fm = xr.baseExperience.featuresManager;
// const xrTest = fm.enableFeature(BABYLON.WebXRHitTest, "latest");
// const anchors = fm.enableFeature(BABYLON.WebXRAnchorSystem, 'latest');
// const xrBackgroundRemover = fm.enableFeature(BABYLON.WebXRBackgroundRemover.Name);
return scene;
};
var ScatterPlot = function(dimensions, labels, scene) {
this.scene = scene;
this.dimensions = {
width: 100,
height: 100,
depth: 100
};
if (dimensions.length > 0) {
if (dimensions[0] != undefined)
this.dimensions.width = parseFloat(dimensions[0]);
if (dimensions[1] != undefined)
this.dimensions.height = parseFloat(dimensions[1]);
if (dimensions[2] != undefined)
this.dimensions.depth = parseFloat(dimensions[2]);
}
this.labelsInfo = {
x: [""],
y: [""],
z: [""]
};
if (Object.keys(labels).length > 0) {
if (labels.x != undefined && Array.isArray(labels.x))
this.labelsInfo.x = labels.x;
if (labels.y != undefined && Array.isArray(labels.y))
this.labelsInfo.y = labels.y;
if (labels.z != undefined && Array.isArray(labels.z))
this.labelsInfo.z = labels.z;
}
this.axis = [];
//infos for dispose;
this._materials = [];
this._meshes = [];
this._textures = [];
//the figure
this.shape = null;
//the entire scatterPlot
this.mesh = new BABYLON.Mesh("scatterPlot", this.scene);
//internals
this._depth = this.dimensions.depth / 2,
this._width = this.dimensions.width / 2,
this._height = this.dimensions.height / 2,
this._a = this.labelsInfo.y.length,
this._b = this.labelsInfo.x.length,
this._c = this.labelsInfo.z.length;
this._color = new BABYLON.Color3(0.3, 0.3, 0.3);
this._defPos = this.mesh.position.clone();
this._addGrid = function(width, height, linesHeight, linesWidth, position, rotation) {
var stepw = 2 * width / linesWidth,
steph = 2 * height / linesHeight;
var verts = [];
//width
for (var i = -width; i <= width; i += stepw) {
verts.push([new BABYLON.Vector3(-height, i, 0), new BABYLON.Vector3(height, i, 0)]);
}
//height
for (var i = -height; i <= height; i += steph) {
verts.push([new BABYLON.Vector3(i, -width, 0), new BABYLON.Vector3(i, width, 0)]);
}
this._BBJSaddGrid(verts, position, rotation);
};
this._BBJSaddGrid = function(verts, position, rotation) {
var line = BABYLON.MeshBuilder.CreateLineSystem("linesystem", {
lines: verts,
updatable: false
}, this.scene);
line.color = this._color;
line.position = position;
line.rotation = rotation;
line.parent = this.mesh;
this.axis.push(line);
this._meshes.push(line);
};
this._addLabel = function(length, data, axis, position) {
var diff = 2 * length / data.length,
p = new BABYLON.Vector3.Zero(),
parent = new BABYLON.Mesh("label_" + axis, this.scene);
for (var i = 0; i < data.length; i++) {
var label = this._BBJSaddLabel(data[i]);
label.position = p.clone();
switch (axis.toLowerCase()) {
case "x":
p.subtractInPlace(new BABYLON.Vector3(diff, 0, 0));
break;
case "y":
p.addInPlace(new BABYLON.Vector3(0, diff, 0));
break;
case "z":
p.subtractInPlace(new BABYLON.Vector3(0, 0, diff));
break;
}
label.parent = parent;
}
parent.position = position;
parent.parent = this.mesh;
this._meshes.push(parent);
};
this._BBJSaddLabel = function(text) {
const planeTexture = new BABYLON.DynamicTexture("dynamic texture", 512, this.scene, true, BABYLON.DynamicTexture.TRILINEAR_SAMPLINGMODE);
planeTexture.drawText(text, null, null, "normal 240px Helvetica", "white", "transparent", true);
var material = new BABYLON.StandardMaterial("outputplane", this.scene);
material.emissiveTexture = planeTexture;
material.opacityTexture = planeTexture;
material.backFaceCulling = true;
material.disableLighting = true;
material.freeze();
var outputplane = BABYLON.Mesh.CreatePlane("outputplane", 10, this.scene, false);
outputplane.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
outputplane.material = material;
this._meshes.push(outputplane);
this._materials.push(material);
this._textures.push(planeTexture);
return outputplane;
};
this.setColor = function(color3) {
if (this.axis.length > 0) {
for (var i = 0; i < this.axis.length; i++) {
this.axis[i].color = color3;
}
}
};
this.setPosition = function(vector3) {
if (this.mesh) {
this.mesh.position = vector3;
}
};
this.setScaling = function(vector3) {
if (this.mesh) {
this.mesh.scaling = vector3;
}
};
this.draw = function(vector3_array, use_objects = false, gridMaterial = false, convertToFlatShadedMesh = false) {
var points = [];
if (vector3_array.length > 0) {
for (var i = 0; i < vector3_array.length; i++) {
points.push(new BABYLON.Vector3(
vector3_array[i].x * (this.dimensions.width / this._b),
vector3_array[i].y * (this.dimensions.height / this._a),
vector3_array[i].z * (this.dimensions.depth / this._c)
));
}
}
if (points.length > 0) {
this._defPos = this.mesh.position.clone();
this.mesh.position = new BABYLON.Vector3(this._width, this._height, this._depth);
if (use_objects) {
var sphere = BABYLON.Mesh.CreateSphere("sphere", 16, 1, this.scene);
var SPS = new BABYLON.SolidParticleSystem('SPS', this.scene);
SPS.addShape(sphere, points.length);
SPS.buildMesh();
sphere.dispose();
SPS.initParticles = function(points, altitude) {
var p = 0;
for (var i = 0; i < points.length; i++) {
SPS.particles[p].position.x = points[i].x;
SPS.particles[p].position.y = points[i].y;
SPS.particles[p].position.z = points[i].z;
SPS.particles[p].scale.x = vector3_array[i].y / 1.5;
SPS.particles[p].scale.y = vector3_array[i].y / 1.5;
SPS.particles[p].scale.z = vector3_array[i].y / 1.5;
SPS.particles[p].color.r = 1.0;
SPS.particles[p].color.g = 1 - vector3_array[i].y / altitude;
SPS.particles[p].color.b = 0.5;
SPS.particles[p].color.a = 1.0;
p++;
}
};
// init all particle values and set them once to apply textures, colors, etc
SPS.initParticles(points, this._a);
SPS.setParticles();
SPS.isAlwaysVisible = true;
SPS.computeParticleRotation = false;
SPS.computeParticleColor = false;
SPS.computeParticleTexture = false;
SPS.mesh.position.subtractInPlace(this.mesh.position);
SPS.mesh.parent = this.mesh;
this._meshes.push(SPS);
this.shape = SPS;
} else {
if (gridMaterial) {
var mat = new BABYLON.GridMaterial("grid", this.scene);
mat.gridRatio = 2;
mat.majorUnitFrequency = 1;
mat.minorUnitVisibility = 0.1;
mat.opacity = 0.98;
mat.mainColor = new BABYLON.Color3(1, 1, 1);
mat.lineColor = new BABYLON.Color3(0, 0, 0);
} else {
var mat = new BABYLON.StandardMaterial("standard", this._scene);
mat.specularColor = new BABYLON.Color3();
}
mat.backFaceCulling = false;
var points_chunk = this._chunk(points, this._c - 1);
var ribbon = BABYLON.Mesh.CreateRibbon("ribbon", points_chunk, false, false, 0, this.scene, true, BABYLON.Mesh.BACKSIDE);
ribbon.material = mat;
var vertexData = new BABYLON.VertexData();
var pdata = ribbon.getVerticesData(BABYLON.VertexBuffer.PositionKind);
var faceColors = [];
for (var i = 0; i < pdata.length; i += 3) {
var coef = (1 - pdata[i + 1] / this._a / 8);
faceColors.push(1, coef, 0.5, 1);
}
vertexData.colors = faceColors;
vertexData.applyToMesh(ribbon, true);
ribbon.useVertexColors = true;
if (convertToFlatShadedMesh) {
ribbon.convertToFlatShadedMesh();
}
ribbon.position.subtractInPlace(this.mesh.position);
ribbon.parent = this.mesh;
this._meshes.push(ribbon);
this._materials.push(mat);
this.shape = ribbon;
}
this.mesh.position = this._defPos;
}
};
this._chunk = function(arr, chunkSize) {
var R = [];
for (var i = 0, len = arr.length; i < len; i += chunkSize)
R.push(arr.slice(i, i + chunkSize));
return R;
};
this.dispose = function(allmeshes = false) {
if (this.shape != null) {
if (this.shape.material != undefined)
this.shape.material.dispose();
this.shape.dispose();
this.shape = null;
}
if (allmeshes) {
if (this._textures.length > 0) {
for (var i = 0; i < this._textures.length; i++) {
this._textures[i].dispose();
}
}
if (this._materials.length > 0) {
for (var i = 0; i < this._materials.length; i++) {
this._materials[i].dispose();
}
}
if (this._meshes.length > 0) {
for (var i = 0; i < this._meshes.length; i++) {
this._meshes[i].dispose();
}
}
if (this.mesh != null) {
if (this.mesh.material != null)
this.mesh.material.dispose();
this.mesh.dispose();
}
this._meshes = [];
this._materials = [];
this._textures = [];
this.mesh = null;
delete this;
}
}
//create items
this._addGrid(this._height, this._width, this._b, this._a, new BABYLON.Vector3(0, 0, -this._depth), BABYLON.Vector3.Zero());
this._addGrid(this._depth, this._width, this._b, this._c, new BABYLON.Vector3(0, -this._height, 0), new BABYLON.Vector3(Math.PI / 2, 0, 0));
this._addGrid(this._height, this._depth, this._c, this._a, new BABYLON.Vector3(-this._width, 0, 0), new BABYLON.Vector3(0, Math.PI / 2, 0));
this._addLabel(this._width, this.labelsInfo.x, "x", new BABYLON.Vector3(this._width, -(this._height + 2), -this._depth));
this._addLabel(this._height, this.labelsInfo.y, "y", new BABYLON.Vector3(this._width, -this._height, -(this._depth + 4)));
this._addLabel(this._depth, this.labelsInfo.z, "z", new BABYLON.Vector3(this._width + 2, -(this._height + 2), this._depth));
return this;
}
function roundToTwo(num) {
return +(Math.round(num + "e+2") + "e-2");
};
function showWorldAxis(size) {
var makeTextPlane = function(text, color, size) {
var dynamicTexture = new BABYLON.DynamicTexture("DynamicTexture", 50, scene, true);
dynamicTexture.hasAlpha = true;
dynamicTexture.drawText(text, 5, 40, "bold 36px Arial", color, "transparent", true);
var plane = BABYLON.Mesh.CreatePlane("TextPlane", size, scene, true);
plane.material = new BABYLON.StandardMaterial("TextPlaneMaterial", scene);
plane.material.backFaceCulling = false;
plane.material.specularColor = new BABYLON.Color3(0, 0, 0);
plane.material.diffuseTexture = dynamicTexture;
return plane;
};
var axisX = BABYLON.Mesh.CreateLines("axisX", [
BABYLON.Vector3.Zero(), new BABYLON.Vector3(size, 0, 0), new BABYLON.Vector3(size * 0.95, 0.05 * size, 0),
new BABYLON.Vector3(size, 0, 0), new BABYLON.Vector3(size * 0.95, -0.05 * size, 0)
], scene);
axisX.color = new BABYLON.Color3(1, 0, 0);
var xChar = makeTextPlane("X", "red", size / 10);
xChar.position = new BABYLON.Vector3(0.9 * size, -0.05 * size, 0);
var axisY = BABYLON.Mesh.CreateLines("axisY", [
BABYLON.Vector3.Zero(), new BABYLON.Vector3(0, size, 0), new BABYLON.Vector3(-0.05 * size, size * 0.95, 0),
new BABYLON.Vector3(0, size, 0), new BABYLON.Vector3(0.05 * size, size * 0.95, 0)
], scene);
axisY.color = new BABYLON.Color3(0, 1, 0);
var yChar = makeTextPlane("Y", "green", size / 10);
yChar.position = new BABYLON.Vector3(0, 0.9 * size, -0.05 * size);
var axisZ = BABYLON.Mesh.CreateLines("axisZ", [
BABYLON.Vector3.Zero(), new BABYLON.Vector3(0, 0, size), new BABYLON.Vector3(0, -0.05 * size, size * 0.95),
new BABYLON.Vector3(0, 0, size), new BABYLON.Vector3(0, 0.05 * size, size * 0.95)
], scene);
axisZ.color = new BABYLON.Color3(0, 0, 1);
var zChar = makeTextPlane("Z", "blue", size / 10);
zChar.position = new BABYLON.Vector3(0, 0.05 * size, 0.9 * size);
};
window.initFunction = async function() {
var asyncEngineCreation = async function() {
try {
return createDefaultEngine();
} catch (e) {
console.log("the available createEngine function failed. Creating the default engine instead");
return createDefaultEngine();
}
}
window.engine = await asyncEngineCreation();
if (!engine) throw 'engine should not be null.';
window.scene = createScene();
};
initFunction().then(() => {
sceneToRender = scene
engine.runRenderLoop(function() {
if (sceneToRender && sceneToRender.activeCamera) {
sceneToRender.render();
}
});
});
// Resize
window.addEventListener("resize", function() {
engine.resize();
});
</script>
<!-- Partner: AI Automation by Neu AI (https://neu.ie) -->
<div id="partner-neu"><p>Partner: <a href="https://neu.ie">Neu AI Automation</a></p></div>
</body>
</html>