mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
Refactor default three material from Main Material to individual classes
This commit is contained in:
parent
fff36604c4
commit
fddfbee115
8
src/materials/BasicMaterial.ts
Normal file
8
src/materials/BasicMaterial.ts
Normal 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))
|
8
src/materials/LambertMaterial.ts
Normal file
8
src/materials/LambertMaterial.ts
Normal 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));
|
@ -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))
|
||||
|
8
src/materials/PhongMaterial.ts
Normal file
8
src/materials/PhongMaterial.ts
Normal 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))
|
8
src/materials/PhysicalMaterial.ts
Normal file
8
src/materials/PhysicalMaterial.ts
Normal 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))
|
8
src/materials/PointsMaterial.ts
Normal file
8
src/materials/PointsMaterial.ts
Normal 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))
|
9
src/materials/ShadowMaterial.ts
Normal file
9
src/materials/ShadowMaterial.ts
Normal 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))
|
8
src/materials/StandardMaterial.ts
Normal file
8
src/materials/StandardMaterial.ts
Normal 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))
|
8
src/materials/ToonMaterial.ts
Normal file
8
src/materials/ToonMaterial.ts
Normal 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))
|
Loading…
Reference in New Issue
Block a user