1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

defineComponent for materials (#10)

This commit is contained in:
Kevin Levron 2021-04-04 20:42:35 +02:00
parent 09290f9d88
commit a1d786297c
13 changed files with 39 additions and 33 deletions

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { MeshBasicMaterial } from 'three'; import { MeshBasicMaterial } from 'three';
import { bindProps, propsValues } from '../tools'; import { bindProps, propsValues } from '../tools';
import Material, { wireframeProps } from './Material'; import Material, { wireframeProps } from './Material';
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
...wireframeProps, ...wireframeProps,
@ -16,4 +17,4 @@ export default {
}, },
}, },
__hmrId: 'BasicMaterial', __hmrId: 'BasicMaterial',
}; });

View File

@ -1,7 +1,7 @@
import { defineComponent, watch } from 'vue';
import { CubeTextureLoader, CubeRefractionMapping } from 'three'; import { CubeTextureLoader, CubeRefractionMapping } from 'three';
import { watch } from 'vue';
export default { export default defineComponent({
inject: ['material'], inject: ['material'],
emits: ['loaded'], emits: ['loaded'],
props: { props: {
@ -49,4 +49,4 @@ export default {
render() { render() {
return []; return [];
}, },
}; });

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { MeshLambertMaterial } from 'three'; import { MeshLambertMaterial } from 'three';
import { bindProps, propsValues } from '../tools'; import { bindProps, propsValues } from '../tools';
import Material, { wireframeProps } from './Material'; import Material, { wireframeProps } from './Material';
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
...wireframeProps, ...wireframeProps,
@ -16,4 +17,4 @@ export default {
}, },
}, },
__hmrId: 'LambertMaterial', __hmrId: 'LambertMaterial',
}; });

View File

@ -1,6 +1,7 @@
import { defineComponent } from 'vue';
import Texture from './Texture.js'; import Texture from './Texture.js';
export default { export default defineComponent({
extends: Texture, extends: Texture,
inject: ['material'], inject: ['material'],
created() { created() {
@ -16,4 +17,4 @@ export default {
}, },
}, },
__hmrId: 'Map', __hmrId: 'Map',
}; });

View File

@ -1,9 +1,9 @@
import { defineComponent } from 'vue';
import { MeshMatcapMaterial, TextureLoader } from 'three'; import { MeshMatcapMaterial, TextureLoader } from 'three';
// import { watch } from 'vue';
import { propsValues, getMatcapUrl } from '../tools'; import { propsValues, getMatcapUrl } from '../tools';
import Material from './Material'; import Material from './Material';
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
src: String, src: String,
@ -22,4 +22,4 @@ export default {
}, },
}, },
__hmrId: 'MatcapMaterial', __hmrId: 'MatcapMaterial',
}; });

View File

@ -1,7 +1,7 @@
import { watch } from 'vue'; import { defineComponent, watch } from 'vue';
import { FrontSide } from 'three'; import { FrontSide } from 'three';
export default { export default defineComponent({
inject: ['three', 'mesh'], inject: ['three', 'mesh'],
props: { props: {
color: { type: [String, Number], default: '#ffffff' }, color: { type: [String, Number], default: '#ffffff' },
@ -52,7 +52,7 @@ export default {
return this.$slots.default ? this.$slots.default() : []; return this.$slots.default ? this.$slots.default() : [];
}, },
__hmrId: 'Material', __hmrId: 'Material',
}; });
export const wireframeProps = { export const wireframeProps = {
wireframe: { type: Boolean, default: false }, wireframe: { type: Boolean, default: false },

View File

@ -1,9 +1,9 @@
import { defineComponent, watch } from 'vue';
import { MeshPhongMaterial } from 'three'; import { MeshPhongMaterial } from 'three';
import { watch } from 'vue';
import { bindProps, propsValues } from '../tools'; import { bindProps, propsValues } from '../tools';
import Material, { wireframeProps } from './Material'; import Material, { wireframeProps } from './Material';
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
emissive: { type: [Number, String], default: 0 }, emissive: { type: [Number, String], default: 0 },
@ -33,4 +33,4 @@ export default {
}, },
}, },
__hmrId: 'PhongMaterial', __hmrId: 'PhongMaterial',
}; });

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { MeshPhysicalMaterial } from 'three'; import { MeshPhysicalMaterial } from 'three';
import { propsValues } from '../tools'; import { propsValues } from '../tools';
import StandardMaterial from './StandardMaterial'; import StandardMaterial from './StandardMaterial';
export default { export default defineComponent({
extends: StandardMaterial, extends: StandardMaterial,
props: { props: {
flatShading: Boolean, flatShading: Boolean,
@ -16,4 +17,4 @@ export default {
}, },
}, },
__hmrId: 'PhysicalMaterial', __hmrId: 'PhysicalMaterial',
}; });

View File

@ -1,8 +1,8 @@
import { defineComponent, watch } from 'vue';
import { ShaderMaterial } from 'three'; import { ShaderMaterial } from 'three';
import { watch } from 'vue';
import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools'; import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools';
export default { export default defineComponent({
inject: ['three', 'mesh'], inject: ['three', 'mesh'],
props: { props: {
uniforms: { type: Object, default: () => { return {}; } }, uniforms: { type: Object, default: () => { return {}; } },
@ -37,4 +37,4 @@ export default {
return this.$slots.default ? this.$slots.default() : []; return this.$slots.default ? this.$slots.default() : [];
}, },
__hmrId: 'ShaderMaterial', __hmrId: 'ShaderMaterial',
}; });

View File

@ -1,5 +1,5 @@
import { defineComponent, watch } from 'vue';
import { MeshStandardMaterial } from 'three'; import { MeshStandardMaterial } from 'three';
import { watch } from 'vue';
import { bindProp, bindProps, propsValues } from '../tools'; import { bindProp, bindProps, propsValues } from '../tools';
import Material, { wireframeProps } from './Material'; import Material, { wireframeProps } from './Material';
@ -19,7 +19,7 @@ const props = {
flatShading: Boolean, flatShading: Boolean,
}; };
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
...props, ...props,
@ -46,4 +46,4 @@ export default {
}, },
}, },
__hmrId: 'StandardMaterial', __hmrId: 'StandardMaterial',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { Color, ShaderMaterial as TShaderMaterial, UniformsUtils } from 'three'; import { Color, ShaderMaterial as TShaderMaterial, UniformsUtils } from 'three';
import SubsurfaceScatteringShader from './SubsurfaceScatteringShader.js'; import SubsurfaceScatteringShader from './SubsurfaceScatteringShader.js';
export default { export default defineComponent({
inject: ['three', 'mesh'], inject: ['three', 'mesh'],
props: { props: {
color: { type: String, default: '#ffffff' }, color: { type: String, default: '#ffffff' },
@ -51,4 +52,4 @@ export default {
return []; return [];
}, },
__hmrId: 'SubSurfaceMaterial', __hmrId: 'SubSurfaceMaterial',
}; });

View File

@ -1,8 +1,8 @@
import { defineComponent, watch } from 'vue';
import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, TextureLoader, UVMapping } from 'three'; import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, TextureLoader, UVMapping } from 'three';
import { watch } from 'vue';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
export default { export default defineComponent({
inject: ['material'], inject: ['material'],
emits: ['loaded'], emits: ['loaded'],
props: { props: {
@ -57,4 +57,4 @@ export default {
}, },
}, },
render() { return []; }, render() { return []; },
}; });

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { MeshToonMaterial } from 'three'; import { MeshToonMaterial } from 'three';
import { bindProps, propsValues } from '../tools'; import { bindProps, propsValues } from '../tools';
import Material, { wireframeProps } from './Material'; import Material, { wireframeProps } from './Material';
export default { export default defineComponent({
extends: Material, extends: Material,
props: { props: {
...wireframeProps, ...wireframeProps,
@ -16,4 +17,4 @@ export default {
}, },
}, },
__hmrId: 'ToonMaterial', __hmrId: 'ToonMaterial',
}; });