-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv3.js
62 lines (47 loc) · 1.65 KB
/
env3.js
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
// creates a nice 3d environment 3 - inside a planet
// idea: another variant is just to put planet in some location (random f(radius) or manual...)
// and to rotate it from timer or better as a parameter..
// questions: who should control position,rotation,scale (user from gui on target object? or in current object?)
// thus this env is an env "inside a planet" or just some asset with predefined values and parameters?
// bug: saturn ring
var planets = [
"custom",
"Callisto_1_4821.glb",
"EarthClouds_1_12756.glb",
"Earth_1_12756.glb",
"Io_1_3643.glb",
"Mars_1_6792.glb",
"Neptune_1_49528.glb",
"Saturn_1_120536.glb",
"Venus(surface)_1_12103.glb",
"Vesta_1_100.glb"
];
function getplaneturl(i) {
return "https://viewlang.ru/assets/planets/"+planets[i];
}
export default function setup( vz ) {
function make( opts ) {
var obj = vz.create_obj( {}, opts );
var gltf = vz.vis.addGltf( obj, "item" );
// todo check assigned? or in gltf?
function reflect() {
var v = obj.getParam("preset");
if (v > 0) {
gltf.setParam("src",getplaneturl(v) );
}
}
obj.addCombo( "preset",1,planets,reflect );
obj.setParam( "preset",1 );
gltf.track("loaded",function() {
gltf.sceneObject.children[0].material.side=2;
});
obj.addSlider( "scale",50,0,100,0.1,function(v) {
gltf.scale = v;
});
obj.addCmd( "Nasa 3d items",function() {
window.open("https://solarsystem.nasa.gov/resources/all/?order=pub_date+desc&per_page=50&page=0&search=&condition_1=1%3Ais_in_resource_list&fs=&fc=324&ft=&dp=&category=324");
});
return obj;
}
vz.addItemType( "env3","Background Env 3 (planets)",make,{cat: "background"} );
}