-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemotest5.html
120 lines (96 loc) · 4.17 KB
/
demotest5.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demotest RadialCloner</title>
<!-- Babylon.js -->
<script src="lib/b3alpha.max.js"></script>
<script src="lib/babylon.objFileLoader.js"></script>
<script src="lib/babylon.marbleProceduralTexture.js"></script>
<script src="lib/babylon.skyMaterial.js"></script>
<script src="lib/dat.gui.min.js"></script>
<script src="src/babylonx.cloner.js"></script>
<style>
html,
body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0px;
background-color: #333344;
}
#renderCanvas {
width: 100%;
height: 100%;
padding: 0px;
}
.dg {
color: #00AA00;
text-shadow: none !important;
}
</style>
</head>
<body bgcolor="#333344" oncontextmenu="return false; ">
<canvas id="renderCanvas"></canvas>
<script>
//helper for demonstration purpose only
//normally you would create your own scene an objects here
var demo = new BABYLONX.Demoscene();
//var cube1 = demo.createCube({ w: 1, h: 1, d: 1 }, "#DAA520");
//var cube2 = demo.createCube({ w: .5, h: .5, d: .5 }, "#DCDCDC");
//var sph = demo.createSphere(2, "#55FFDC");
//helper -end
var skyMaterial = new BABYLON.SkyMaterial("skyMaterial", demo.scene);
skyMaterial.backFaceCulling = false;
var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, demo.scene);
skybox.material = skyMaterial;
var skyMaterial = new BABYLON.SkyMaterial("skyMaterial", demo.scene);
skyMaterial.backFaceCulling = false;
var assets = [];
var toLoad = [
{ name: "colo", src: "assets/c4d/coloseum/", file: "coloseum.obj" },
];
var loader = new BABYLON.AssetsManager(demo.scene);
toLoad.forEach(function (obj) {
var img = loader.addMeshTask(obj.name, "", obj.src, obj.file);
//img.onSuccess = function(t) {
// assets[t.name] = t.loadedMeshes[0];
//};
});
loader.onFinish = function (tasks) {
// Create meshes
var groundMaterial = new BABYLON.StandardMaterial("groundTex", demo.scene);
groundMaterial.diffuseTexture = new BABYLON.Texture("assets/dirt.jpg", demo.scene);
groundMaterial.diffuseColor = new BABYLON.Color3(0.2, 0, 0);
// Generate a mesh using a loaded from JPG file height map.
var ground = BABYLON.Mesh.CreateGroundFromHeightMap("groundHeight", "assets/ground.jpg", 80, 80, 150, 0, .2, demo.scene, false);
ground.material = groundMaterial;
tasks.forEach(function (obj) {
var lm = obj.loadedMeshes;
assets[obj.name] = obj.loadedMeshes[0];
});
var obj = assets["colo"];
let rg = new BABYLONX.RandomNumberGen({ min: 2, max:4, seed: 21 });
var lc4 = new BABYLONX.LinearCloner([obj], demo.scene, { useInstances:true,iModeRelative: true, count: rg, P: { x: 0, y: 2, z: 0 } });
var rc = new BABYLONX.RadialCloner([lc4], demo.scene, { offset:30,startangle: 65, count: 50, radius: 12 });
let reff = new BABYLONX.RandomEffector().rot({ x: 1, y: 1, z: 1 }).pos({ x: .1, y: .2, z: .1 }).str(1).updateClients();
rc.addEffector(reff, 1);
}
loader.load();
//demo.scene.debugLayer.show();
var frame = 0;
demo.scene.registerBeforeRender(function () {
frame++;
if (frame == 150) {
//demo.scene.materials.forEach(function(m){
// m.diffuseTexture.hasAlpha = true;
//});
var mbyname = demo.scene.getMaterialByName("Mat");
mbyname.diffuseTexture.hasAlpha = true;
mbyname.specularColor = new BABYLON.Color3(0, 0, 0);
}
});
</script>
</body>
</html>