mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
wip
This commit is contained in:
parent
10a11e152d
commit
1611539d63
@ -28,6 +28,10 @@ Thanks to VueJS/ViteJS, **TroisJS use watchers and HMR to update ThreeJS objects
|
|||||||
- [x] Material : color, depthTest, depthWrite, fog, opacity, transparent
|
- [x] Material : color, depthTest, depthWrite, fog, opacity, transparent
|
||||||
- [x] StandardMaterial : emissive, emissiveIntensity, metalness, roughness
|
- [x] StandardMaterial : emissive, emissiveIntensity, metalness, roughness
|
||||||
- [x] Mesh : position, rotation, scale, castShadow, receiveShadow
|
- [x] Mesh : position, rotation, scale, castShadow, receiveShadow
|
||||||
|
- [x] Box (geometry replace) : size, width, height, depth
|
||||||
|
- [x] Plane (geometry replace) : width, height, widthSegments, heightSegments
|
||||||
|
- [x] Sphere (geometry replace) : radius, widthSegments, heightSegments
|
||||||
|
- [x] Text (geometry replace) : all props except fontSrc (wip)
|
||||||
- [ ] ...
|
- [ ] ...
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export { default as EffectComposer } from './EffectComposer.js';
|
export { default as EffectComposer } from './EffectComposer.js';
|
||||||
export { default as RenderPass } from './RenderPass.js';
|
export { default as RenderPass } from './RenderPass.js';
|
||||||
export { default as BokehPass } from './BokehPass.js';
|
export { default as BokehPass } from './BokehPass.js';
|
||||||
|
export { default as FilmPass } from './FilmPass.js';
|
||||||
export { default as UnrealBloomPass } from './UnrealBloomPass.js';
|
export { default as UnrealBloomPass } from './UnrealBloomPass.js';
|
||||||
|
@ -20,12 +20,23 @@ export default {
|
|||||||
default: 1,
|
default: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
size() { this.refreshGeometry(); },
|
||||||
|
width() { this.refreshGeometry(); },
|
||||||
|
height() { this.refreshGeometry(); },
|
||||||
|
depth() { this.refreshGeometry(); },
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.size) {
|
this.createGeometry();
|
||||||
this.geometry = new BoxBufferGeometry(this.size, this.size, this.size);
|
},
|
||||||
} else {
|
methods: {
|
||||||
this.geometry = new BoxBufferGeometry(this.width, this.height, this.depth);
|
createGeometry() {
|
||||||
}
|
if (this.size) {
|
||||||
|
this.geometry = new BoxBufferGeometry(this.size, this.size, this.size);
|
||||||
|
} else {
|
||||||
|
this.geometry = new BoxBufferGeometry(this.width, this.height, this.depth);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
__hmrId: 'Box',
|
__hmrId: 'Box',
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,12 @@ export default {
|
|||||||
this.scene.add(this.mesh);
|
this.scene.add(this.mesh);
|
||||||
this.$emit('ready');
|
this.$emit('ready');
|
||||||
},
|
},
|
||||||
|
refreshGeometry() {
|
||||||
|
const oldGeo = this.geometry;
|
||||||
|
this.createGeometry();
|
||||||
|
this.mesh.geometry = this.geometry;
|
||||||
|
oldGeo.dispose();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
return [];
|
return [];
|
||||||
|
@ -21,8 +21,19 @@ export default {
|
|||||||
default: 1,
|
default: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
width() { this.refreshGeometry(); },
|
||||||
|
height() { this.refreshGeometry(); },
|
||||||
|
widthSegments() { this.refreshGeometry(); },
|
||||||
|
heightSegments() { this.refreshGeometry(); },
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.geometry = new PlaneBufferGeometry(this.width, this.height, this.widthSegments, this.heightSegments);
|
this.createGeometry();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
createGeometry() {
|
||||||
|
this.geometry = new PlaneBufferGeometry(this.width, this.height, this.widthSegments, this.heightSegments);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
__hmrId: 'Plane',
|
__hmrId: 'Plane',
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,18 @@ export default {
|
|||||||
default: 12,
|
default: 12,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
radius() { this.refreshGeometry(); },
|
||||||
|
widthSegments() { this.refreshGeometry(); },
|
||||||
|
heightSegments() { this.refreshGeometry(); },
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.geometry = new SphereBufferGeometry(this.radius, this.widthSegments, this.heightSegments);
|
this.createGeometry();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
createGeometry() {
|
||||||
|
this.geometry = new SphereBufferGeometry(this.radius, this.widthSegments, this.heightSegments);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
__hmrId: 'Sphere',
|
__hmrId: 'Sphere',
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,6 @@ export default {
|
|||||||
this.$emit('loaded');
|
this.$emit('loaded');
|
||||||
},
|
},
|
||||||
updateUV() {
|
updateUV() {
|
||||||
// console.log(this.texture);
|
|
||||||
this.iWidth = this.texture.image.width;
|
this.iWidth = this.texture.image.width;
|
||||||
this.iHeight = this.texture.image.height;
|
this.iHeight = this.texture.image.height;
|
||||||
this.iRatio = this.iWidth / this.iHeight;
|
this.iRatio = this.iWidth / this.iHeight;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { FontLoader, TextBufferGeometry } from 'three';
|
import { FontLoader, TextBufferGeometry } from 'three';
|
||||||
import Mesh from './Mesh.js';
|
import Mesh from './Mesh.js';
|
||||||
|
import { watch } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Mesh,
|
extends: Mesh,
|
||||||
@ -18,11 +19,29 @@ export default {
|
|||||||
align: { type: [Boolean, String], default: false },
|
align: { type: [Boolean, String], default: false },
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
// add watchers
|
||||||
|
const watchProps = [
|
||||||
|
'text', 'size', 'height', 'curveSegments',
|
||||||
|
'bevelEnabled', 'bevelThickness', 'bevelSize', 'bevelOffset', 'bevelSegments',
|
||||||
|
'align',
|
||||||
|
];
|
||||||
|
watchProps.forEach(p => {
|
||||||
|
watch(() => this[p], () => {
|
||||||
|
if (this.font) this.refreshGeometry();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const loader = new FontLoader();
|
const loader = new FontLoader();
|
||||||
loader.load(this.fontSrc, (font) => {
|
loader.load(this.fontSrc, (font) => {
|
||||||
this.font = font;
|
this.font = font;
|
||||||
|
this.createGeometry();
|
||||||
|
this.initMesh();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
createGeometry() {
|
||||||
this.geometry = new TextBufferGeometry(this.text, {
|
this.geometry = new TextBufferGeometry(this.text, {
|
||||||
font,
|
font: this.font,
|
||||||
size: this.size,
|
size: this.size,
|
||||||
height: this.height,
|
height: this.height,
|
||||||
depth: this.depth,
|
depth: this.depth,
|
||||||
@ -37,8 +56,6 @@ export default {
|
|||||||
if (this.align === 'center') {
|
if (this.align === 'center') {
|
||||||
this.geometry.center();
|
this.geometry.center();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
this.initMesh();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user