mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
Merge branch 'upstream' into raycast-update
This commit is contained in:
commit
157d918728
@ -3,16 +3,16 @@
|
||||
*Trois* is a french word, it means *Three*.
|
||||
|
||||
<p>
|
||||
<a href="https://troisjs.github.io/little-planet/"><img src="/screenshots/little-planet.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/demos/3.html"><img src="/screenshots/troisjs_1.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/demos/4.html"><img src="/screenshots/troisjs_3.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/demos/1.html"><img src="/screenshots/troisjs_4.jpg" width="30%" /></a>
|
||||
<!-- <a href="https://troisjs.github.io/examples/demos/1.html"><img src="/screenshots/troisjs_4.jpg" width="30%" /></a> -->
|
||||
<a href="https://troisjs.github.io/examples/demos/2.html"><img src="/screenshots/troisjs_5.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/materials/2.html"><img src="/screenshots/troisjs_2.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/loop.html"><img src="/screenshots/troisjs_6.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/shadows.html"><img src="/screenshots/troisjs_7.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/demos/5.html"><img src="/screenshots/troisjs_8.jpg" width="30%" /></a>
|
||||
<a href="https://troisjs.github.io/examples/lights.html"><img src="/screenshots/troisjs_9.jpg" width="30%" /></a>
|
||||
|
||||
</p>
|
||||
|
||||
- 💻 Examples (wip) : https://troisjs.github.io/ ([sources](https://github.com/troisjs/troisjs.github.io/tree/master/src/components))
|
||||
|
BIN
screenshots/little-planet.jpg
Normal file
BIN
screenshots/little-planet.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
@ -37,8 +37,7 @@ export default {
|
||||
height: this.three.size.height,
|
||||
};
|
||||
const pass = new BokehPass(this.three.scene, this.three.camera, params);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'BokehPass',
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
export default {
|
||||
inject: ['three', 'passes'],
|
||||
events: ['ready'],
|
||||
beforeMount() {
|
||||
if (!this.passes) {
|
||||
console.error('Missing parent EffectComposer');
|
||||
@ -8,6 +9,13 @@ export default {
|
||||
unmounted() {
|
||||
if (this.pass.dispose) this.pass.dispose();
|
||||
},
|
||||
methods: {
|
||||
completePass(pass) {
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.$emit('ready', pass);
|
||||
}
|
||||
},
|
||||
render() {
|
||||
return [];
|
||||
},
|
||||
|
@ -6,8 +6,7 @@ export default {
|
||||
extends: EffectPass,
|
||||
mounted() {
|
||||
const pass = new ShaderPass(FXAAShader);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
|
||||
// resize will be called in three init
|
||||
this.three.onAfterResize(this.resize);
|
||||
|
@ -29,8 +29,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
const pass = new FilmPass(this.noiseIntensity, this.scanlinesIntensity, this.scanlinesCount, this.grayscale);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'FilmPass',
|
||||
};
|
||||
|
@ -22,8 +22,7 @@ export default {
|
||||
});
|
||||
});
|
||||
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'HalftonePass',
|
||||
};
|
||||
|
@ -11,8 +11,7 @@ export default {
|
||||
console.error('Missing Camera');
|
||||
}
|
||||
const pass = new RenderPass(this.three.scene, this.three.camera);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'RenderPass',
|
||||
};
|
||||
|
@ -6,8 +6,7 @@ export default {
|
||||
mounted() {
|
||||
// three size is not set yet, but this pass will be resized by effect composer
|
||||
const pass = new SMAAPass(this.three.size.width, this.three.size.height);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'SMAAPass',
|
||||
};
|
||||
|
39
src/effects/SSAOPass.js
Normal file
39
src/effects/SSAOPass.js
Normal file
@ -0,0 +1,39 @@
|
||||
import { SSAOPass } from 'three/examples/jsm/postprocessing/SSAOPass.js';
|
||||
import EffectPass from './EffectPass.js';
|
||||
|
||||
export default {
|
||||
extends: EffectPass,
|
||||
props: {
|
||||
scene: null,
|
||||
camera: null,
|
||||
options: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const pass = new SSAOPass(
|
||||
this.scene || this.three.scene,
|
||||
this.camera || this.three.camera,
|
||||
this.three.size.width,
|
||||
this.three.size.height
|
||||
);
|
||||
this.completePass(pass);
|
||||
|
||||
for (let key of Object.keys(this.options)) {
|
||||
this.pass[key] = this.options[key];
|
||||
}
|
||||
// resize will be called in three init
|
||||
this.three.onAfterResize(this.resize);
|
||||
},
|
||||
unmounted() {
|
||||
this.three.offAfterResize(this.resize);
|
||||
},
|
||||
methods: {
|
||||
resize() {
|
||||
this.pass.width = this.three.size.width
|
||||
this.pass.height = this.three.size.height
|
||||
},
|
||||
},
|
||||
__hmrId: 'SSAOPass',
|
||||
};
|
@ -39,6 +39,10 @@ export default {
|
||||
this.pass.setSize = (width, height) => {
|
||||
uniforms.texSize.value.set(width, height);
|
||||
};
|
||||
|
||||
// emit ready event with two passes - do so manually in this file instead
|
||||
// of calling `completePass` like in other effect types
|
||||
this.$emit('ready', [this.pass, this.pass1])
|
||||
},
|
||||
methods: {
|
||||
updateFocusLine() {
|
||||
|
@ -17,8 +17,7 @@ export default {
|
||||
mounted() {
|
||||
const size = new Vector2(this.three.size.width, this.three.size.height);
|
||||
const pass = new UnrealBloomPass(size, this.strength, this.radius, this.threshold);
|
||||
this.passes.push(pass);
|
||||
this.pass = pass;
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'UnrealBloomPass',
|
||||
};
|
||||
|
@ -10,12 +10,13 @@ export default {
|
||||
strength: { type: Number, default: 0.5 },
|
||||
},
|
||||
mounted() {
|
||||
this.pass = new ShaderPass(ZoomBlur);
|
||||
this.passes.push(this.pass);
|
||||
const pass = new ShaderPass(ZoomBlur);
|
||||
|
||||
const uniforms = this.uniforms = this.pass.uniforms;
|
||||
const uniforms = this.uniforms = pass.uniforms;
|
||||
bindProp(this, 'center', uniforms.center, 'value');
|
||||
bindProp(this, 'strength', uniforms.strength, 'value');
|
||||
|
||||
this.completePass(pass);
|
||||
},
|
||||
__hmrId: 'ZoomBlurPass',
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ export { default as FilmPass } from './FilmPass.js';
|
||||
export { default as FXAAPass } from './FXAAPass.js';
|
||||
export { default as HalftonePass } from './HalftonePass.js';
|
||||
export { default as SMAAPass } from './SMAAPass.js';
|
||||
export { default as SSAOPass } from './SSAOPass.js';
|
||||
export { default as TiltShiftPass } from './TiltShiftPass.js';
|
||||
export { default as UnrealBloomPass } from './UnrealBloomPass.js';
|
||||
export { default as ZoomBlurPass } from './ZoomBlurPass.js';
|
||||
|
@ -70,6 +70,7 @@ export const TroisJSVuePlugin = {
|
||||
'RenderPass',
|
||||
'SAOPass',
|
||||
'SMAAPass',
|
||||
'SSAOPass',
|
||||
'TiltShiftPass',
|
||||
'UnrealBloomPass',
|
||||
'ZoomBlurPass',
|
||||
|
Loading…
Reference in New Issue
Block a user