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

Refactor default three material from Main Material to individual classes

This commit is contained in:
Yang 2022-03-28 17:29:37 +08:00
parent fff36604c4
commit fddfbee115
9 changed files with 65 additions and 10 deletions

View File

@ -0,0 +1,8 @@
import { materialComponent } from "./Material";
import { PropType } from 'vue';
import { BasicMaterialPropsInterface } from "./types";
import { MeshBasicMaterial } from "three";
export default materialComponent('BasicMaterial',
{ props: { type: Object as PropType<BasicMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshBasicMaterial(opts))

View File

@ -0,0 +1,8 @@
import { MeshLambertMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { LambertMaterialPropsInterface } from "./types";
export default materialComponent('LambertMaterial',
{ props: { type: Object as PropType<LambertMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshLambertMaterial(opts));

View File

@ -92,13 +92,3 @@ export function materialComponent<P extends Readonly<ComponentPropsOptions>>(
}, },
}) })
} }
// TODO : proper
export const BasicMaterial = materialComponent('BasicMaterial', { props: { type: Object as PropType<BasicMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshBasicMaterial(opts))
export const LambertMaterial = materialComponent('LambertMaterial', { props: { type: Object as PropType<LambertMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshLambertMaterial(opts))
export const PhongMaterial = materialComponent('PhongMaterial', { props: { type: Object as PropType<PhongMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshPhongMaterial(opts))
export const PhysicalMaterial = materialComponent('PhysicalMaterial', { props: { type: Object as PropType<PhysicalMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshPhysicalMaterial(opts))
export const PointsMaterial = materialComponent('PointsMaterial', { props: { type: Object as PropType<PointsMaterialPropsInterface>, default: () => ({}) } }, (opts) => new TPointsMaterial(opts))
export const ShadowMaterial = materialComponent('ShadowMaterial', { color: { type: String, default: '#000000' }, props: { type: Object as PropType<MaterialPropsInterface>, default: () => ({}) } }, (opts) => new TShadowMaterial(opts))
export const StandardMaterial = materialComponent('StandardMaterial', { props: { type: Object as PropType<StandardMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshStandardMaterial(opts))
export const ToonMaterial = materialComponent('ToonMaterial', { props: { type: Object as PropType<ToonMaterialPropsInterface>, default: () => ({}) } }, (opts) => new MeshToonMaterial(opts))

View File

@ -0,0 +1,8 @@
import { MeshPhongMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { PhongMaterialPropsInterface } from "./types";
export default materialComponent('PhongMaterial',
{ props: { type: Object as PropType<PhongMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshPhongMaterial(opts))

View File

@ -0,0 +1,8 @@
import { MeshPhysicalMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { PhysicalMaterialPropsInterface } from "./types";
export default materialComponent('PhysicalMaterial',
{ props: { type: Object as PropType<PhysicalMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshPhysicalMaterial(opts))

View File

@ -0,0 +1,8 @@
import { PointsMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { PointsMaterialPropsInterface } from "./types";
export default materialComponent('PointsMaterial',
{ props: { type: Object as PropType<PointsMaterialPropsInterface>, default: () => ({}) } },
(opts) => new PointsMaterial(opts))

View File

@ -0,0 +1,9 @@
import { ShadowMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { MaterialPropsInterface } from "./types";
export default materialComponent('ShadowMaterial',
{ color: { type: String, default: '#000000' },
props: { type: Object as PropType<MaterialPropsInterface>, default: () => ({}) } },
(opts) => new ShadowMaterial(opts))

View File

@ -0,0 +1,8 @@
import { MeshStandardMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { StandardMaterialPropsInterface } from "./types";
export default materialComponent('StandardMaterial',
{ props: { type: Object as PropType<StandardMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshStandardMaterial(opts))

View File

@ -0,0 +1,8 @@
import { MeshToonMaterial } from "three";
import { PropType } from "vue";
import { materialComponent } from "./Material";
import { ToonMaterialPropsInterface } from "./types";
export default materialComponent('ToonMaterial',
{ props: { type: Object as PropType<ToonMaterialPropsInterface>, default: () => ({}) } },
(opts) => new MeshToonMaterial(opts))