Skip to content

Commit

Permalink
🎈 perf: Optimize material display
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Apr 12, 2024
1 parent 6e4c20d commit d5795dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/chili-three/src/threeVisual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ export class ThreeVisual implements IVisual {
initScene() {
let scene = new Scene();
scene.background = new Color(0x888888);
let envLight = new AmbientLight(0x888888, 5);
const light = new DirectionalLight(0xffffff, 0.5);
let envLight = new AmbientLight(0x888888, 4);
let axisHelper = new AxesHelper(250);
scene.add(envLight, axisHelper);
scene.add(light, envLight, axisHelper);
return scene;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/chili-three/src/threeVisualContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class ThreeVisualContext implements IVisualContext {
let map = new TextureLoader().load(item.texture);
map.wrapS = RepeatWrapping;
map.wrapT = RepeatWrapping;
map.center.set(0.5, 0.5);
map.repeat.set(item.repeatU, item.repeatV);
map.rotation = MathUtils.degToRad(item.angle);
return map;
Expand All @@ -112,7 +113,6 @@ export class ThreeVisualContext implements IVisualContext {
material.name = source.name;
} else if (prop === "angle" && material.map) {
material.map.rotation = MathUtils.degToRad(source.angle);
material.map.center.set(0.5, 0.5);
} else if (prop === "repeatU" && material.map) {
material.map.repeat.setX(source.repeatU);
} else if (prop === "repeatV" && material.map) {
Expand Down
2 changes: 1 addition & 1 deletion packages/chili-ui/src/property/material/materialEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MaterialEditor extends HTMLElement {

private initEditingControl(material: Material) {
const selectTexture = async () => {
let file = await readFileAsync(".png, .jpg", false, "readAsDataURL");
let file = await readFileAsync(".png, .jpg, .jpeg", false, "readAsDataURL");
material.texture = file.unwrap()[0].data;
};
let container = div({
Expand Down

0 comments on commit d5795dd

Please sign in to comment.