mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2025-12-11 20:15:30 +01:00
Change MaterialType enum to OtS_MaterialType type
This commit is contained in:
parent
9fae5a4336
commit
4d77a58d17
@ -16,7 +16,7 @@ import { RenderMeshParams, RenderNextBlockMeshChunkParams, RenderNextVoxelMeshCh
|
|||||||
import { UIUtil } from '../../runtime/util/ui_util';
|
import { UIUtil } from '../../runtime/util/ui_util';
|
||||||
import { TAxis } from '../../runtime/util/type_util';
|
import { TAxis } from '../../runtime/util/type_util';
|
||||||
import { Atlas } from '../../runtime/atlas';
|
import { Atlas } from '../../runtime/atlas';
|
||||||
import { Material, MaterialType } from '../../runtime/materials';
|
import { Material } from '../../runtime/materials';
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export enum MeshType {
|
export enum MeshType {
|
||||||
@ -41,7 +41,7 @@ enum EDebugBufferComponents {
|
|||||||
* Dedicated type for passing to shaders for solid materials
|
* Dedicated type for passing to shaders for solid materials
|
||||||
*/
|
*/
|
||||||
type InternalSolidMaterial = {
|
type InternalSolidMaterial = {
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colourArray: number[],
|
colourArray: number[],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ type InternalSolidMaterial = {
|
|||||||
* Dedicated type for passing to shaders for textured materials
|
* Dedicated type for passing to shaders for textured materials
|
||||||
*/
|
*/
|
||||||
type InternalTextureMaterial = {
|
type InternalTextureMaterial = {
|
||||||
type: MaterialType.textured,
|
type: 'textured',
|
||||||
diffuseTexture: WebGLTexture,
|
diffuseTexture: WebGLTexture,
|
||||||
// The texture to sample alpha values from (if is using a texture map)
|
// The texture to sample alpha values from (if is using a texture map)
|
||||||
alphaTexture: WebGLTexture,
|
alphaTexture: WebGLTexture,
|
||||||
@ -328,9 +328,9 @@ export class Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createInternalMaterial(material: Material): (InternalSolidMaterial | InternalTextureMaterial) {
|
private _createInternalMaterial(material: Material): (InternalSolidMaterial | InternalTextureMaterial) {
|
||||||
if (material.type === MaterialType.solid) {
|
if (material.type === 'solid') {
|
||||||
return {
|
return {
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colourArray: RGBAUtil.toArray(material.colour),
|
colourArray: RGBAUtil.toArray(material.colour),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -389,7 +389,7 @@ export class Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: MaterialType.textured,
|
type: 'textured',
|
||||||
diffuseTexture: diffuseTexture,
|
diffuseTexture: diffuseTexture,
|
||||||
alphaTexture: alphaTexture,
|
alphaTexture: alphaTexture,
|
||||||
alphaValue: alphaValue,
|
alphaValue: alphaValue,
|
||||||
@ -565,7 +565,7 @@ export class Renderer {
|
|||||||
|
|
||||||
private _drawMesh() {
|
private _drawMesh() {
|
||||||
this._materialBuffers.forEach((materialBuffer, materialName) => {
|
this._materialBuffers.forEach((materialBuffer, materialName) => {
|
||||||
if (materialBuffer.material.type === MaterialType.textured) {
|
if (materialBuffer.material.type === 'textured') {
|
||||||
this._drawMeshBuffer(materialBuffer.buffer, materialBuffer.numElements, ShaderManager.Get.textureTriProgram!, {
|
this._drawMeshBuffer(materialBuffer.buffer, materialBuffer.numElements, ShaderManager.Get.textureTriProgram!, {
|
||||||
u_lightWorldPos: ArcballCamera.Get.getCameraPosition(-Math.PI/4, 0.0).toArray(),
|
u_lightWorldPos: ArcballCamera.Get.getCameraPosition(-Math.PI/4, 0.0).toArray(),
|
||||||
u_worldViewProjection: ArcballCamera.Get.getWorldViewProjection(),
|
u_worldViewProjection: ArcballCamera.Get.getWorldViewProjection(),
|
||||||
|
|||||||
@ -2,9 +2,9 @@ import { LOC } from '../../localiser';
|
|||||||
import { AppIcons } from '../../../editor/ui/icons';
|
import { AppIcons } from '../../../editor/ui/icons';
|
||||||
import { ConfigComponent } from './config';
|
import { ConfigComponent } from './config';
|
||||||
import { ToolbarItemComponent } from './toolbar_item';
|
import { ToolbarItemComponent } from './toolbar_item';
|
||||||
import { Material, MaterialType } from '../../../runtime/materials';
|
import { Material, OtS_MaterialType } from '../../../runtime/materials';
|
||||||
|
|
||||||
export class MaterialTypeComponent extends ConfigComponent<MaterialType, HTMLDivElement> {
|
export class MaterialTypeComponent extends ConfigComponent<OtS_MaterialType, HTMLDivElement> {
|
||||||
private _solidButton: ToolbarItemComponent;
|
private _solidButton: ToolbarItemComponent;
|
||||||
private _texturedButton: ToolbarItemComponent;
|
private _texturedButton: ToolbarItemComponent;
|
||||||
private _material: Material;
|
private _material: Material;
|
||||||
@ -17,7 +17,7 @@ export class MaterialTypeComponent extends ConfigComponent<MaterialType, HTMLDiv
|
|||||||
.setLabel(LOC('materials.components.solid'))
|
.setLabel(LOC('materials.components.solid'))
|
||||||
.setGrow()
|
.setGrow()
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
if (this._material.type === MaterialType.textured) {
|
if (this._material.type === 'textured') {
|
||||||
this._onClickChangeTypeDelegate?.();
|
this._onClickChangeTypeDelegate?.();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -26,7 +26,7 @@ export class MaterialTypeComponent extends ConfigComponent<MaterialType, HTMLDiv
|
|||||||
.setLabel(LOC('materials.components.textured'))
|
.setLabel(LOC('materials.components.textured'))
|
||||||
.setGrow()
|
.setGrow()
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
if (this._material.type === MaterialType.solid) {
|
if (this._material.type === 'solid') {
|
||||||
this._onClickChangeTypeDelegate?.();
|
this._onClickChangeTypeDelegate?.();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -45,8 +45,8 @@ export class MaterialTypeComponent extends ConfigComponent<MaterialType, HTMLDiv
|
|||||||
this._solidButton.finalise();
|
this._solidButton.finalise();
|
||||||
this._texturedButton.finalise();
|
this._texturedButton.finalise();
|
||||||
|
|
||||||
this._solidButton.setActive(this._material.type === MaterialType.solid);
|
this._solidButton.setActive(this._material.type === 'solid');
|
||||||
this._texturedButton.setActive(this._material.type === MaterialType.textured);
|
this._texturedButton.setActive(this._material.type === 'textured');
|
||||||
}
|
}
|
||||||
|
|
||||||
public override registerEvents(): void {
|
public override registerEvents(): void {
|
||||||
@ -58,7 +58,7 @@ export class MaterialTypeComponent extends ConfigComponent<MaterialType, HTMLDiv
|
|||||||
super._onEnabledChanged();
|
super._onEnabledChanged();
|
||||||
|
|
||||||
this._solidButton.setEnabled(this.enabled);
|
this._solidButton.setEnabled(this.enabled);
|
||||||
this._texturedButton.setEnabled(this.enabled && (this._material.type === MaterialType.textured || this._material.canBeTextured));
|
this._texturedButton.setEnabled(this.enabled && (this._material.type === 'textured' || this._material.canBeTextured));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override _onValueChanged(): void {
|
protected override _onValueChanged(): void {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { ArcballCamera } from '../renderer/camera';
|
|||||||
import { EAppEvent, EventManager } from '../event';
|
import { EAppEvent, EventManager } from '../event';
|
||||||
import { TExporters } from '../../runtime/exporters/exporters';
|
import { TExporters } from '../../runtime/exporters/exporters';
|
||||||
import { LOC, Localiser, TLocalisedString } from '../localiser';
|
import { LOC, Localiser, TLocalisedString } from '../localiser';
|
||||||
import { MaterialMapManager, MaterialType } from '../../runtime/materials';
|
import { MaterialMapManager } from '../../runtime/materials';
|
||||||
import { MeshType, Renderer } from '../renderer/renderer';
|
import { MeshType, Renderer } from '../renderer/renderer';
|
||||||
import { EAction } from '../../runtime/util';
|
import { EAction } from '../../runtime/util';
|
||||||
import { ASSERT } from '../../runtime/util/error_util';
|
import { ASSERT } from '../../runtime/util/error_util';
|
||||||
@ -872,18 +872,18 @@ export class UI {
|
|||||||
this.layoutDull['materials'].componentOrder.push(`placeholder_element`);
|
this.layoutDull['materials'].componentOrder.push(`placeholder_element`);
|
||||||
} else {
|
} else {
|
||||||
materialManager.toMaterialArray().forEach((material) => {
|
materialManager.toMaterialArray().forEach((material) => {
|
||||||
if (material.type === MaterialType.solid) {
|
if (material.type === 'solid') {
|
||||||
this.layoutDull['materials'].components[`mat_${material.name}`] = new SolidMaterialComponent(material.name, material)
|
this.layoutDull['materials'].components[`mat_${material.name}`] = new SolidMaterialComponent(material.name, material)
|
||||||
.setUnlocalisedLabel(material.name)
|
.setUnlocalisedLabel(material.name)
|
||||||
.onChangeTypeDelegate(() => {
|
.onChangeTypeDelegate(() => {
|
||||||
materialManager.changeMaterialType(material.name, MaterialType.textured);
|
materialManager.changeMaterialType(material.name, 'textured');
|
||||||
this.updateMaterialsAction(materialManager);
|
this.updateMaterialsAction(materialManager);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.layoutDull['materials'].components[`mat_${material.name}`] = new TexturedMaterialComponent(material.name, material)
|
this.layoutDull['materials'].components[`mat_${material.name}`] = new TexturedMaterialComponent(material.name, material)
|
||||||
.setUnlocalisedLabel(material.name)
|
.setUnlocalisedLabel(material.name)
|
||||||
.onChangeTypeDelegate(() => {
|
.onChangeTypeDelegate(() => {
|
||||||
materialManager.changeMaterialType(material.name, MaterialType.solid);
|
materialManager.changeMaterialType(material.name, 'solid');
|
||||||
this.updateMaterialsAction(materialManager);
|
this.updateMaterialsAction(materialManager);
|
||||||
})
|
})
|
||||||
.onChangeTransparencyTypeDelegate((newTransparency) => {
|
.onChangeTransparencyTypeDelegate((newTransparency) => {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { UV } from '../util';
|
|||||||
import { Vector3 } from '../vector';
|
import { Vector3 } from '../vector';
|
||||||
import { IImporter } from './base_importer';
|
import { IImporter } from './base_importer';
|
||||||
import { OtS_Mesh, TEMP_CONVERT_MESH, Tri } from '../ots_mesh';
|
import { OtS_Mesh, TEMP_CONVERT_MESH, Tri } from '../ots_mesh';
|
||||||
import { Material, MaterialType } from '../materials';
|
import { Material } from '../materials';
|
||||||
|
|
||||||
export type TGltfImporterError =
|
export type TGltfImporterError =
|
||||||
| { type: 'failed-to-parse' }
|
| { type: 'failed-to-parse' }
|
||||||
@ -44,9 +44,8 @@ export class GltfLoader extends IImporter {
|
|||||||
const meshMaterials: Map<string, Material> = new Map();
|
const meshMaterials: Map<string, Material> = new Map();
|
||||||
meshMaterials.set('NONE', {
|
meshMaterials.set('NONE', {
|
||||||
name: 'NONE',
|
name: 'NONE',
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
||||||
needsAttention: false,
|
|
||||||
canBeTextured: false,
|
canBeTextured: false,
|
||||||
});
|
});
|
||||||
let maxIndex = 0;
|
let maxIndex = 0;
|
||||||
@ -111,22 +110,20 @@ export class GltfLoader extends IImporter {
|
|||||||
|
|
||||||
meshMaterials.set(materialName, {
|
meshMaterials.set(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.textured,
|
type: 'textured',
|
||||||
diffuse: {
|
diffuse: {
|
||||||
filetype: mimeType === 'image/jpeg' ? 'jpg' : 'png',
|
filetype: mimeType === 'image/jpeg' ? 'jpg' : 'png',
|
||||||
raw: (mimeType === 'image/jpeg' ? 'data:image/jpeg;base64,' : 'data:image/png;base64,') + base64,
|
raw: (mimeType === 'image/jpeg' ? 'data:image/jpeg;base64,' : 'data:image/png;base64,') + base64,
|
||||||
},
|
},
|
||||||
extension: 'clamp',
|
extension: 'clamp',
|
||||||
interpolation: 'linear',
|
interpolation: 'linear',
|
||||||
needsAttention: false,
|
|
||||||
transparency: { type: 'None' },
|
transparency: { type: 'None' },
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
meshMaterials.set(materialName, {
|
meshMaterials.set(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
||||||
needsAttention: false,
|
|
||||||
canBeTextured: true,
|
canBeTextured: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -144,14 +141,13 @@ export class GltfLoader extends IImporter {
|
|||||||
if (diffuseColour !== undefined) {
|
if (diffuseColour !== undefined) {
|
||||||
meshMaterials.set(materialName, {
|
meshMaterials.set(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colour: {
|
colour: {
|
||||||
r: diffuseColour[0],
|
r: diffuseColour[0],
|
||||||
g: diffuseColour[1],
|
g: diffuseColour[1],
|
||||||
b: diffuseColour[2],
|
b: diffuseColour[2],
|
||||||
a: diffuseColour[3],
|
a: diffuseColour[3],
|
||||||
},
|
},
|
||||||
needsAttention: false,
|
|
||||||
canBeTextured: false,
|
canBeTextured: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -165,14 +161,13 @@ export class GltfLoader extends IImporter {
|
|||||||
if (!materialMade && emissiveColour !== undefined) {
|
if (!materialMade && emissiveColour !== undefined) {
|
||||||
meshMaterials.set(materialName, {
|
meshMaterials.set(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colour: {
|
colour: {
|
||||||
r: emissiveColour[0],
|
r: emissiveColour[0],
|
||||||
g: emissiveColour[1],
|
g: emissiveColour[1],
|
||||||
b: emissiveColour[2],
|
b: emissiveColour[2],
|
||||||
a: 1.0,
|
a: 1.0,
|
||||||
},
|
},
|
||||||
needsAttention: false,
|
|
||||||
canBeTextured: false,
|
canBeTextured: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,20 +3,19 @@ import { EImageChannel, TImageRawWrap, TTransparencyOptions, TTransparencyTypes
|
|||||||
import { ASSERT } from './util/error_util';
|
import { ASSERT } from './util/error_util';
|
||||||
import { TTexelExtension, TTexelInterpolation } from './util/type_util';
|
import { TTexelExtension, TTexelInterpolation } from './util/type_util';
|
||||||
|
|
||||||
export enum MaterialType { solid, textured }
|
export type OtS_MaterialType = 'solid' | 'textured';
|
||||||
|
|
||||||
type BaseMaterial = {
|
type BaseMaterial = {
|
||||||
name: string,
|
name: string,
|
||||||
needsAttention: boolean, // True if the user should make edits to this material
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SolidMaterial = BaseMaterial & {
|
export type SolidMaterial = BaseMaterial & {
|
||||||
type: MaterialType.solid,
|
type: 'solid'
|
||||||
colour: RGBA,
|
colour: RGBA,
|
||||||
canBeTextured: boolean,
|
canBeTextured: boolean,
|
||||||
}
|
}
|
||||||
export type TexturedMaterial = BaseMaterial & {
|
export type TexturedMaterial = BaseMaterial & {
|
||||||
type: MaterialType.textured,
|
type: 'textured',
|
||||||
diffuse?: TImageRawWrap,
|
diffuse?: TImageRawWrap,
|
||||||
interpolation: TTexelInterpolation,
|
interpolation: TTexelInterpolation,
|
||||||
extension: TTexelExtension,
|
extension: TTexelExtension,
|
||||||
@ -57,7 +56,7 @@ export class MaterialMapManager {
|
|||||||
public changeTransparencyType(materialName: string, newTransparencyType: TTransparencyTypes) {
|
public changeTransparencyType(materialName: string, newTransparencyType: TTransparencyTypes) {
|
||||||
const currentMaterial = this.getMaterial(materialName);
|
const currentMaterial = this.getMaterial(materialName);
|
||||||
ASSERT(currentMaterial !== undefined, 'Cannot change transparency type of non-existent material');
|
ASSERT(currentMaterial !== undefined, 'Cannot change transparency type of non-existent material');
|
||||||
ASSERT(currentMaterial.type === MaterialType.textured);
|
ASSERT(currentMaterial.type === 'textured');
|
||||||
|
|
||||||
switch (newTransparencyType) {
|
switch (newTransparencyType) {
|
||||||
case 'None':
|
case 'None':
|
||||||
@ -90,7 +89,7 @@ export class MaterialMapManager {
|
|||||||
* Convert a material to a new type, i.e. textured to solid.
|
* Convert a material to a new type, i.e. textured to solid.
|
||||||
* Will return if the material is already the given type.
|
* Will return if the material is already the given type.
|
||||||
*/
|
*/
|
||||||
public changeMaterialType(materialName: string, newMaterialType: MaterialType) {
|
public changeMaterialType(materialName: string, newMaterialType: OtS_MaterialType) {
|
||||||
const currentMaterial = this.getMaterial(materialName);
|
const currentMaterial = this.getMaterial(materialName);
|
||||||
ASSERT(currentMaterial !== undefined, 'Cannot change material type of non-existent material');
|
ASSERT(currentMaterial !== undefined, 'Cannot change material type of non-existent material');
|
||||||
|
|
||||||
@ -99,27 +98,25 @@ export class MaterialMapManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (newMaterialType) {
|
switch (newMaterialType) {
|
||||||
case MaterialType.solid:
|
case 'solid':
|
||||||
ASSERT(currentMaterial.type === MaterialType.textured, 'Old material expect to be texture');
|
ASSERT(currentMaterial.type === 'textured', 'Old material expect to be texture');
|
||||||
this._setMaterial(materialName, {
|
this._setMaterial(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.solid,
|
type: 'solid',
|
||||||
colour: RGBAUtil.randomPretty(),
|
colour: RGBAUtil.randomPretty(),
|
||||||
canBeTextured: true,
|
canBeTextured: true,
|
||||||
needsAttention: true,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case MaterialType.textured:
|
case 'textured':
|
||||||
ASSERT(currentMaterial.type === MaterialType.solid, 'Old material expect to be solid');
|
ASSERT(currentMaterial.type === 'solid', 'Old material expect to be solid');
|
||||||
this._setMaterial(materialName, {
|
this._setMaterial(materialName, {
|
||||||
name: materialName,
|
name: materialName,
|
||||||
type: MaterialType.textured,
|
type: 'textured',
|
||||||
transparency: {
|
transparency: {
|
||||||
type: 'None',
|
type: 'None',
|
||||||
},
|
},
|
||||||
extension: 'repeat',
|
extension: 'repeat',
|
||||||
interpolation: 'linear',
|
interpolation: 'linear',
|
||||||
needsAttention: true,
|
|
||||||
diffuse: undefined,
|
diffuse: undefined,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Bounds } from './bounds';
|
import { Bounds } from './bounds';
|
||||||
import { RGBAColours, RGBAUtil } from './colour';
|
import { RGBAColours, RGBAUtil } from './colour';
|
||||||
import { Material, MaterialMapManager, MaterialType, SolidMaterial } from './materials';
|
import { Material, MaterialMapManager, SolidMaterial } from './materials';
|
||||||
import { degreesToRadians } from './math';
|
import { degreesToRadians } from './math';
|
||||||
import { UV } from "./util";
|
import { UV } from "./util";
|
||||||
import { Vector3 } from "./vector";
|
import { Vector3 } from "./vector";
|
||||||
@ -121,7 +121,7 @@ export class OtS_Mesh {
|
|||||||
for (let i = 0; i < this._materials.length; ++i) {
|
for (let i = 0; i < this._materials.length; ++i) {
|
||||||
const oldMaterial = this._materials[i];
|
const oldMaterial = this._materials[i];
|
||||||
if (oldMaterial.name === newMaterial.name) {
|
if (oldMaterial.name === newMaterial.name) {
|
||||||
if (oldMaterial.type === MaterialType.solid && newMaterial.type === MaterialType.textured && !oldMaterial.canBeTextured) {
|
if (oldMaterial.type === 'solid' && newMaterial.type === 'textured' && !oldMaterial.canBeTextured) {
|
||||||
return false; // Assigning a texture material to a non-textureable material
|
return false; // Assigning a texture material to a non-textureable material
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,8 +255,7 @@ export function TEMP_CONVERT_MESH(vertices: Vector3[], uvs: UV[], tris: Tri[]):
|
|||||||
name: materialName,
|
name: materialName,
|
||||||
canBeTextured: hasTexcoords,
|
canBeTextured: hasTexcoords,
|
||||||
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
colour: RGBAUtil.copy(RGBAColours.WHITE),
|
||||||
needsAttention: false,
|
type: 'solid',
|
||||||
type: MaterialType.solid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
materials.push(material);
|
materials.push(material);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { MaterialType } from "./materials";
|
|
||||||
import { OtS_Mesh } from "./ots_mesh";
|
import { OtS_Mesh } from "./ots_mesh";
|
||||||
import { Texture } from "./texture";
|
import { Texture } from "./texture";
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ export class OtS_Mesh_TextureLoader {
|
|||||||
this._textures.clear();
|
this._textures.clear();
|
||||||
|
|
||||||
mesh.getMaterials().forEach((material) => {
|
mesh.getMaterials().forEach((material) => {
|
||||||
if (material.type === MaterialType.textured) {
|
if (material.type === 'textured') {
|
||||||
this._textures.set(
|
this._textures.set(
|
||||||
material.name,
|
material.name,
|
||||||
new Texture({
|
new Texture({
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import { RGBA, RGBAColours, RGBAUtil } from './colour';
|
|||||||
import { OtS_Mesh, OtS_Triangle } from './ots_mesh';
|
import { OtS_Mesh, OtS_Triangle } from './ots_mesh';
|
||||||
import { ASSERT } from './util/error_util';
|
import { ASSERT } from './util/error_util';
|
||||||
import { OtS_Mesh_TextureLoader } from './ots_mesh_texture_loader';
|
import { OtS_Mesh_TextureLoader } from './ots_mesh_texture_loader';
|
||||||
import { MaterialType } from './materials';
|
|
||||||
|
|
||||||
export type OtS_VoxelMesh_ConverterConfig = {
|
export type OtS_VoxelMesh_ConverterConfig = {
|
||||||
constraintAxis: TAxis,
|
constraintAxis: TAxis,
|
||||||
@ -128,7 +127,7 @@ export class OtS_VoxelMesh_Converter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _getVoxelColour(mesh: OtS_Mesh, triangle: OtS_Triangle, location: Vector3): RGBA {
|
private _getVoxelColour(mesh: OtS_Mesh, triangle: OtS_Triangle, location: Vector3): RGBA {
|
||||||
if (triangle.material.type === MaterialType.solid) {
|
if (triangle.material.type === 'solid') {
|
||||||
return RGBAUtil.copy(triangle.material.colour);
|
return RGBAUtil.copy(triangle.material.colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +149,7 @@ export class OtS_VoxelMesh_Converter {
|
|||||||
RGBAUtil.copy(RGBAColours.MAGENTA);
|
RGBAUtil.copy(RGBAColours.MAGENTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(triangle.material.type === MaterialType.textured);
|
ASSERT(triangle.material.type === 'textured');
|
||||||
const texture = this._textureLoader.getTexture(triangle.material.name);
|
const texture = this._textureLoader.getTexture(triangle.material.name);
|
||||||
if (texture !== undefined) {
|
if (texture !== undefined) {
|
||||||
return texture.getRGBA(uv, triangle.material.interpolation, triangle.material.extension);
|
return texture.getRGBA(uv, triangle.material.interpolation, triangle.material.extension);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user