Skip to content

Commit d96db5d

Browse files
committed
use mipmap texture setting
1 parent 3e40bfb commit d96db5d

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/nodes/texture/ImageTextureNode.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,29 @@ import { UVTransformProperty } from "../../properties/UVTransformProperty";
77
import { TextureTypeNode } from "./BaseTextureNode";
88
import { Script } from '../../export/Script';
99
import { TextureColorSpaceProperty } from '../../properties/TextureColorSpaceProperty';
10+
import { TextureInterpolationProperty } from '../../properties/TextureInterpolationProperty';
11+
import { ComboBoxProperty } from '../../properties/ComboBoxProperty';
1012
export class ImageTextureNode extends TextureTypeNode {
1113

1214
private imageProp:TextureProperty;
1315
private uv:UVTransformProperty;
1416
private extensionPolicy:TextureExtensionProperty;
1517
private mappingPolicy:TextureMappingModeProperty;
1618
private colorSpace:TextureColorSpaceProperty;
19+
private interpolation:TextureInterpolationProperty;
20+
private useMipmaps:ComboBoxProperty;
1721

1822
constructor() {
1923
super("Image Texture",
2024
[
2125
new Vector3Output("Color"),
2226
new Vector1Output("Alpha").outputProp("a"),
2327
new TextureProperty(),
28+
new ComboBoxProperty("generate Mipmaps", [
29+
["true", "use Mipmaps"],
30+
["false", "Don't use Mipmaps"]
31+
]),
32+
new TextureInterpolationProperty(),
2433
new TextureExtensionProperty(),
2534
new TextureMappingModeProperty(),
2635
new TextureColorSpaceProperty(),
@@ -33,6 +42,8 @@ export class ImageTextureNode extends TextureTypeNode {
3342
this.extensionPolicy = this.getChildOfType(TextureExtensionProperty)!;
3443
this.mappingPolicy = this.getChildOfType(TextureMappingModeProperty)!;
3544
this.colorSpace = this.getChildOfType(TextureColorSpaceProperty)!;
45+
this.interpolation = this.getChildOfType(TextureInterpolationProperty)!;
46+
this.useMipmaps = this.getChildOfType(ComboBoxProperty)!;
3647
}
3748

3849
override writeScript(script: Script): string {
@@ -52,7 +63,9 @@ ${texture}.wrapT = ${ this.extensionPolicy.value };
5263
${texture}.mapping = ${ this.mappingPolicy.value };
5364
${texture}.colorSpace = ${ this.colorSpace.value };
5465
${texture}.flipY = false;
55-
`
66+
${texture}.generateMipmaps = ${ this.useMipmaps.value };
67+
${ this.interpolation.returnTextureSetupJs(texture) }
68+
`
5669
) ;
5770

5871
const uv = this.uv.writeScript(script);
@@ -67,7 +80,9 @@ ${texture}.flipY = false;
6780
src: this.imageProp.isFromDisk? "" : this.imageProp.imageSrc,
6881
extension: this.extensionPolicy.value,
6982
mapping: this.mappingPolicy.value,
70-
colorSpace: this.colorSpace.value
83+
colorSpace: this.colorSpace.value,
84+
interpolation: this.interpolation.value,
85+
usemipmap: this.useMipmaps.value,
7186
}
7287
}
7388

@@ -80,6 +95,8 @@ ${texture}.flipY = false;
8095
this.extensionPolicy.value = data.extension;
8196
this.mappingPolicy.value = data.mapping;
8297
this.colorSpace.value = data.colorSpace;
98+
this.interpolation.value = data.interpolation;
99+
this.useMipmaps.value = data.usemipmap;
83100
}
84101

85102
override onRemoved(): void {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComboBoxProperty } from "./ComboBoxProperty";
2+
3+
export class TextureInterpolationProperty extends ComboBoxProperty {
4+
constructor() {
5+
super("Interpolation",[
6+
[ "THREE.NearestFilter", "Nearest" ],
7+
[ "THREE.LinearFilter", "Linear" ],
8+
[ "THREE.NearestMipmapNearestFilter", "Nearest, Mipmap Nearest" ],
9+
[ "THREE.NearestMipmapLinearFilter", "Nearest, Mipmap Linear" ],
10+
[ "THREE.LinearMipmapNearestFilter", "Linear, Mipmap Nearest" ],
11+
[ "THREE.LinearMipmapLinearFilter", "Linear, Mipmap Linear" ],
12+
]);
13+
}
14+
15+
returnTextureSetupJs( textureName:string ) {
16+
17+
return `
18+
${ textureName}.magFilter = ${ this.value.includes(".Linear")? this.modes[0][0] : this.modes[1][0] };
19+
${ textureName}.minFilter = ${ this.value };
20+
`;
21+
}
22+
}

0 commit comments

Comments
 (0)