本文整理汇总了TypeScript中THREE.TextureLoader类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextureLoader类的具体用法?TypeScript TextureLoader怎么用?TypeScript TextureLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureLoader类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function(options: any) {
// EARTH
var container = new THREE.Object3D();
let earthGeometry = new THREE.SphereGeometry(options.size, 100, 100);
let loader = new THREE.TextureLoader();
let t1 = loader.load('img/earthmap1k.jpg', function(texture) {});
let t2 = loader.load('img/earthbump1k.jpg', function(texture) {});
let t3 = loader.load('img/earthspec1k.jpg', function(texture) {});
let earthMaterial = new THREE.MeshPhongMaterial({
map: t1,
bumpMap: t2,
bumpScale: 0.05,
specularMap: t3, // shininess on oceans
specular: 0x808080,
// side: THREE.DoubleSide
});
// EARTH GLOW
// var earthGlowMaterial = THREEx.createAtmosphereMaterial();
// earthGlowMaterial.uniforms.glowColor.value.set(0x00b3ff);
// earthGlowMaterial.uniforms.coeficient.value = 0.8;
// earthGlowMaterial.uniforms.power.value = 2.0;
// var earthGlow = new THREE.Mesh(earthGeometry, earthGlowMaterial);
// earthGlow.scale.multiplyScalar(1.02);
// earthGlow.position = earth.position;
// container.add(earth);
// container.add(earthGlow);
let earth = new THREE.Mesh(earthGeometry, earthMaterial);
// earth.receiveShadow = true;
// earth.castShadow = true;
// renderStack.push(function(now, delta) {
// earth.rotation.y += (1/8 * delta) / 1000;
// });
return container;
};
示例2: load
public load(key: string, imageSize: ImageSize): rx.Observable<THREE.Texture> {
let textureLoader: THREE.TextureLoader = new THREE.TextureLoader();
textureLoader.setCrossOrigin("Anonymous");
let load: (url: string) => rx.Observable<THREE.Texture> =
rx.Observable.fromCallback<THREE.Texture, string>(
textureLoader.load,
textureLoader);
let textureSource: rx.Observable<THREE.Texture> =
load(Urls.image(key, imageSize))
.do(
(texture: THREE.Texture): void => {
texture.minFilter = THREE.LinearFilter;
texture.needsUpdate = true;
});
return textureSource;
}
示例3:
export const logoPlateFactory = () => {
const textureLoader = new THREE.TextureLoader();
const texture = textureLoader.load('/assets/images/logo@x2.png');
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.format = THREE.RGBFormat;
const geometry = new THREE.PlaneBufferGeometry(2048, 2048, 1, 1);
const material = new THREE.MeshBasicMaterial({
color: 0xffffff,
map: texture,
fog: false,
transparent: false,
});
const logo = new THREE.Mesh(geometry, material);
logo.visible = false;
return logo;
};
示例4: constructor
constructor(
sceneA: SimpleScene,
sceneB: SimpleScene,
transitionParams: TransitionParams
) {
this._sceneA = sceneA;
this._sceneB = sceneB;
this._transitionParams = transitionParams;
this._scene = new THREE.Scene();
this._cameraOrtho = new THREE.OrthographicCamera(
window.innerWidth / -2,
window.innerWidth / 2,
window.innerHeight / 2,
window.innerHeight / -2,
-10,
10
);
this._textures = [];
const textureLoader = new THREE.TextureLoader();
for (let i = 0; i < 6; i++)
this._textures[i] = textureLoader.load(
'/assets/images/transition/transition' + (i + 1) + '.png'
);
this._quadmaterial = new THREE.ShaderMaterial({
uniforms: {
tDiffuse1: {
type: 't',
value: null,
},
tDiffuse2: {
type: 't',
value: null,
},
mixRatio: {
type: 'f',
value: 0.0,
},
threshold: {
type: 'f',
value: 0.1,
},
useTexture: {
type: 'i',
value: 1,
},
tMixTexture: {
type: 't',
value: this._textures[0],
},
},
vertexShader: [
'varying vec2 vUv;',
'void main() {',
'vUv = vec2( uv.x, uv.y );',
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
'}',
].join('\n'),
fragmentShader: [
'uniform float mixRatio;',
'uniform sampler2D tDiffuse1;',
'uniform sampler2D tDiffuse2;',
'uniform sampler2D tMixTexture;',
'uniform int useTexture;',
'uniform float threshold;',
'varying vec2 vUv;',
'void main() {',
'vec4 texel1 = texture2D( tDiffuse1, vUv );',
'vec4 texel2 = texture2D( tDiffuse2, vUv );',
'if (useTexture==1) {',
'vec4 transitionTexel = texture2D( tMixTexture, vUv );',
'float r = mixRatio * (1.0 + threshold * 2.0) - threshold;',
'float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);',
'gl_FragColor = mix( texel1, texel2, mixf );',
'} else {',
'gl_FragColor = mix( texel2, texel1, mixRatio );',
'}',
'}',
].join('\n'),
});
const quadgeometry = new THREE.PlaneBufferGeometry(
window.innerWidth,
window.innerHeight
);
//.........这里部分代码省略.........
示例5: TextureLoader
import {
TextureLoader,
Vector3,
Color
} from "three";
import Star from "./star";
var loader = new TextureLoader();
var sunTexture = loader.load("sun.jpg");
var ioTexture = loader.load("io.jpg");
var jupiterTexture = loader.load("jupiter.jpg");
var marsTexture = loader.load("mars.jpg");
var neptuneTexture = loader.load("neptune.jpg");
var saturnTexture = loader.load("saturn.jpg");
var uranusTexture = loader.load("uranus.jpg");
var venusTexture = loader.load("venus.jpg");
var trantorTexture = loader.load("trantor.png");
export class Sun extends Star {
constructor(position: Vector3) {
super(position, {
color: new Color(0xFB7516),
texture: sunTexture,
displayHalo: true,
applyDistortion: true,
size: 20000
})
}
}