openworld Tutorials
openworld is developed in Flutter and builds upon the developer’s existing Three.js open-world repository, openworldthreejs. It leverages the three_dart
package, simplifying the process of converting Three.js code to three_dart
.
https://pub.dev/packages/openworld
Examples
// Example of adding skydome to openworld
var skyGeo = THREE.SphereGeometry(-1000, 32, 15);
var skyMat = new THREE.ShaderMaterial(SkyShader);
var sky = THREE.Mesh(skyGeo, skyMat);
scene.add(sky);
skyMat.uniforms = {
'turbidity': {'value': 10.0},
'reileigh': {'value': 2.0},
'mieCoefficient': {'value': 0.005},
'mieDirectionalG': {'value': 0.8},
'luminance': {'value': 1.0},
'inclination': {'value': 0},
'azimuth': {'value': 0},
'opacity': {'value': 1.0},
'sunPosition': {'value': THREE.Vector3(0, 100, 0)}
};
// Add Sun
var sunSphere = THREE.Mesh(THREE.SphereGeometry(20000, 16, 8),
THREE.MeshBasicMaterial({'color': THREE.Color.fromHex(0xffffff)}));
sunSphere.position.y = -700000;
sunSphere.visible = true;
var sunlight = new THREE.SpotLight(0x888888);//ffffff);
sunlight.intensity = 0.4;
sunlight.penumbra = 1;
sunSphere.add(sunlight);
scene.add(sunSphere);
// Openworld will change sky depending on time of day
OPENWORLD.Time.init(sunSphere, skyMat, ambience);