JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://dl.dropboxusercontent.com/u/1142760/static/html/webgl/webgl2/libs/jquery.js"></script>
<script src="https://dl.dropboxusercontent.com/u/1142760/static/html/webgl/webgl2/libs/jquery.mousewheel.js"></script>
<script src="https://dl.dropboxusercontent.com/u/1142760/static/html/webgl/webgl2/libs/Three.js"></script>
<script src="https://dl.dropboxusercontent.com/u/1142760/static/html/webgl/webgl2/libs/RequestAnimationFrame.js"></script>
<script src="https://dl.dropboxusercontent.com/u/1142760/static/html/webgl/webgl2/libs/sim/sim.js"></script>
<div id='container' style="width:720; height:480px">
</div>
JavaScript
var map_size = 80;
var MapModel = {};
var types_amount = 2;
var floorMap = [];
for(var i=1; i<=map_size; i++){
floorMap[i]=[];
for(var j=1; j<=map_size; j++){
var ran = Math.ceil(Math.random()*types_amount);
switch(ran){
case 1:
floorMap[i][j]='grass';
break;
case 2:
floorMap[i][j]='water';
break;
}
}
}
MapModel.floorMap = floorMap;
var objectMap = [];
for(var i = map_size; i>=1; i--){
objectMap[i] = [];
for(var j=1; j<=map_size; j++){
objectMap[i][j] = [];
var rand = Math.ceil(Math.random()*2);
switch(rand){
case 1:
objectMap[i][j].push('tree');
break;
}
}
}
MapModel.objectMap = objectMap;
block_size=100;
// Constructor
MapApp = function()
{
Sim.App.call(this);
}
// Subclass Sim.App
MapApp.prototype = new Sim.App();
// Our custom initializer
MapApp.prototype.init = function(param)
{
Sim.App.prototype.init.call(this, param);
// Create the Earth and add it to our sim
for(var i=1; i<=map_size; i++){
for(var j=map_size; j>=1; j--){
var square = new Square();
square.init(i, j);
this.addObject(square);
var arr = MapModel.objectMap[i][j];
for(var k in arr){
var obj = new MapObject();
obj.init(i, j, arr[k]);
this.addObject(obj);
}
}
}
// Let there be light!
var sun = new Sun();
sun.init();
this.addObject(sun);
this.camera.position.x = 3*block_size;
this.camera.position.y = 3*block_size;
this.camera.position.z=5*block_size;
this.camera.rotation.x = Math.round(45* 100* Math.PI/180)/100;
this.selfUpdate = function(){
this.camera.position.x += 0.125 * block_size/10;
this.camera.position.x += 0.050 * block_size/10;
}
}
// Custom Earth class
Square = function()
{
Sim.Object.call(this);
this.size = block_size;
}
Square.prototype = new Sim.Object();
wrote2 =...