mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
WIP preview scenes
This commit is contained in:
parent
876aa0e580
commit
669be56ed6
@ -131,6 +131,7 @@
|
||||
<script src="js/animations/timeline_animators.js"></script>
|
||||
<script src="js/animations/keyframe.js"></script>
|
||||
<script src="js/animations/timeline.js"></script>
|
||||
<script src="js/preview/preview_scenes.js"></script>
|
||||
<script src="js/plugin_loader.js"></script>
|
||||
|
||||
<script src="js/io/codec.js"></script>
|
||||
|
@ -875,6 +875,7 @@ const MenuBar = {
|
||||
'fullscreen',
|
||||
'_',
|
||||
'view_mode',
|
||||
'preview_scene',
|
||||
'toggle_shading',
|
||||
'toggle_motion_trails',
|
||||
'toggle_ground_plane',
|
||||
|
@ -223,6 +223,7 @@ new Property(ModelFormat, 'boolean', 'canvas_limit');
|
||||
new Property(ModelFormat, 'boolean', 'rotation_limit');
|
||||
new Property(ModelFormat, 'boolean', 'uv_rotation');
|
||||
new Property(ModelFormat, 'boolean', 'animation_files');
|
||||
new Property(ModelFormat, 'boolean', 'preview_scenes');
|
||||
new Property(ModelFormat, 'boolean', 'pose_mode');
|
||||
new Property(ModelFormat, 'boolean', 'display_mode');
|
||||
new Property(ModelFormat, 'boolean', 'animation_mode');
|
||||
|
@ -1068,6 +1068,7 @@ var format = new ModelFormat({
|
||||
animated_textures: true,
|
||||
animation_files: true,
|
||||
animation_mode: true,
|
||||
preview_scenes: true,
|
||||
locators: true,
|
||||
texture_meshes: true,
|
||||
codec
|
||||
|
@ -498,10 +498,10 @@ var format = new ModelFormat({
|
||||
animated_textures: true,
|
||||
animation_files: true,
|
||||
animation_mode: true,
|
||||
preview_scenes: true,
|
||||
locators: true,
|
||||
codec,
|
||||
})
|
||||
//Object.defineProperty(format, 'single_texture', {get: _ => !settings.layered_textures.value})
|
||||
codec.format = format;
|
||||
|
||||
BARS.defineActions(function() {
|
||||
|
@ -408,6 +408,8 @@ const Canvas = {
|
||||
})
|
||||
})(),
|
||||
transparentMaterial: new THREE.MeshBasicMaterial({visible: false, name: 'invisible'}),
|
||||
global_light_color: new THREE.Color(0xffffff),
|
||||
|
||||
gridMaterial: new THREE.LineBasicMaterial({color: gizmo_colors.grid}),
|
||||
buildGrid() {
|
||||
three_grid.children.length = 0;
|
||||
|
@ -2009,7 +2009,7 @@ function updateShading() {
|
||||
Texture.all.forEach(tex => {
|
||||
let material = tex.getMaterial();
|
||||
material.uniforms.SHADE.value = settings.shading.value;
|
||||
material.uniforms.BRIGHTNESS.value = settings.brightness.value / 50;
|
||||
material.uniforms.LIGHTCOLOR.value.copy(Canvas.global_light_color).multiplyScalar(settings.brightness.value / 50);
|
||||
})
|
||||
Canvas.emptyMaterials.forEach(material => {
|
||||
material.uniforms.SHADE.value = settings.shading.value;
|
||||
|
63
js/preview/preview_scenes.js
Normal file
63
js/preview/preview_scenes.js
Normal file
@ -0,0 +1,63 @@
|
||||
class PreviewScene {
|
||||
constructor(id, data) {
|
||||
PreviewScene.scenes[id] = this;
|
||||
this.id = id;
|
||||
|
||||
this.name = tl(data.name || `preview_scene.${id}`);
|
||||
this.light_color = data.light_color || {r: 1, g: 1, b: 1};
|
||||
this.condition = data.condition;
|
||||
}
|
||||
select() {
|
||||
console.log(this.light_color)
|
||||
Canvas.global_light_color.copy(this.light_color);
|
||||
updateShading();
|
||||
}
|
||||
unselect() {
|
||||
Canvas.global_light_color.set(0xffffff);
|
||||
updateShading();
|
||||
}
|
||||
}
|
||||
PreviewScene.scenes = {};
|
||||
PreviewScene.active = null;
|
||||
|
||||
|
||||
|
||||
new PreviewScene('minecraft_nether', {
|
||||
light_color: {r: 0.68, g: 0.61, b: 0.49}
|
||||
});
|
||||
new PreviewScene('minecraft_end', {
|
||||
light_color: {r: 0.45, g: 0.52, b: 0.48}
|
||||
});
|
||||
|
||||
|
||||
BARS.defineActions(function() {
|
||||
new BarSelect('preview_scene', {
|
||||
category: 'view',
|
||||
condition: () => Format && Format.preview_scenes,
|
||||
value: 'none',
|
||||
options: {
|
||||
none: tl('generic.none'),
|
||||
minecraft_nether: 'Nether',
|
||||
minecraft_end: 'The End'
|
||||
},
|
||||
/*
|
||||
options() {
|
||||
let opts = {
|
||||
none: tl('generic.none')
|
||||
}
|
||||
for (let id in PreviewScene.scenes) {
|
||||
let scene = PreviewScene.scenes[id];
|
||||
opts[id] = scene.name;
|
||||
}
|
||||
return opts;
|
||||
},*/
|
||||
onChange() {
|
||||
let scene = PreviewScene.scenes[this.value];
|
||||
if (scene) {
|
||||
scene.select();
|
||||
} else if (PreviewScene.active) {
|
||||
PreviewScene.active.unselect();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
@ -109,7 +109,7 @@ class Texture {
|
||||
|
||||
uniform bool SHADE;
|
||||
uniform bool EMISSIVE;
|
||||
uniform float BRIGHTNESS;
|
||||
uniform vec3 LIGHTCOLOR;
|
||||
|
||||
varying vec2 vUv;
|
||||
varying float light;
|
||||
@ -123,12 +123,17 @@ class Texture {
|
||||
|
||||
if (EMISSIVE == false) {
|
||||
|
||||
gl_FragColor = vec4(lift + color.rgb * light * BRIGHTNESS, color.a);
|
||||
gl_FragColor = vec4(lift + color.rgb * light, color.a);
|
||||
gl_FragColor.r = gl_FragColor.r * LIGHTCOLOR.r;
|
||||
gl_FragColor.g = gl_FragColor.g * LIGHTCOLOR.g;
|
||||
gl_FragColor.b = gl_FragColor.b * LIGHTCOLOR.b;
|
||||
|
||||
} else {
|
||||
|
||||
float light2 = (light * BRIGHTNESS) + (1.0 - light * BRIGHTNESS) * (1.0 - color.a);
|
||||
gl_FragColor = vec4(lift + color.rgb * light2, 1.0);
|
||||
float light_r = (light * LIGHTCOLOR.r) + (1.0 - light * LIGHTCOLOR.r) * (1.0 - color.a);
|
||||
float light_g = (light * LIGHTCOLOR.g) + (1.0 - light * LIGHTCOLOR.g) * (1.0 - color.a);
|
||||
float light_b = (light * LIGHTCOLOR.b) + (1.0 - light * LIGHTCOLOR.b) * (1.0 - color.a);
|
||||
gl_FragColor = vec4(lift + color.r * light_r, lift + color.g * light_g, lift + color.b * light_b, 1.0);
|
||||
|
||||
}
|
||||
|
||||
@ -141,7 +146,7 @@ class Texture {
|
||||
uniforms: {
|
||||
map: {type: 't', value: tex},
|
||||
SHADE: {type: 'bool', value: settings.shading.value},
|
||||
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
|
||||
LIGHTCOLOR: {type: 'vec3', value: new THREE.Color().copy(Canvas.global_light_color).multiplyScalar(settings.brightness.value / 50)},
|
||||
EMISSIVE: {type: 'bool', value: this.render_mode == 'emissive'}
|
||||
},
|
||||
vertexShader: vertShader,
|
||||
|
@ -1196,6 +1196,8 @@
|
||||
"action.view_mode.wireframe": "Wireframe",
|
||||
"action.view_mode.uv": "UV Preview",
|
||||
"action.view_mode.normal": "Face Normal",
|
||||
"action.preview_scene": "Preview Scene",
|
||||
"action.preview_scene.desc": "Change the model preview scene",
|
||||
"action.screenshot_model": "Screenshot Model",
|
||||
"action.screenshot_model.desc": "Take a cropped screenshot of the model from the current angle",
|
||||
"action.record_model_gif": "Record GIF...",
|
||||
|
Loading…
Reference in New Issue
Block a user