Skip to content

Commit

Permalink
Merge pull request #128 from jbbe/add-MeshDepthMaterial
Browse files Browse the repository at this point in the history
Initial implementation of MeshDepthMaterial issue #77
  • Loading branch information
trusktr authored Aug 8, 2021
2 parents 30b76e5 + 0798272 commit 0060e3d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 111 deletions.
25 changes: 0 additions & 25 deletions src/as/materials/MeshDepthMaterial.d.ts

This file was deleted.

86 changes: 0 additions & 86 deletions src/as/materials/MeshDepthMaterial.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/as/materials/MeshDepthMaterial.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @author jbbe / https://github.com/jbbe
*/

import {MeshDepthMaterial} from './MeshDepthMaterial'

describe('Materials', () => {
describe('MeshDepthMaterial', () => {
test('type', () => {
const mat = new MeshDepthMaterial()
expect(mat.type).toBe('MeshDepthMaterial', 'it should be true')
})

todo('copy')
})
})
88 changes: 88 additions & 0 deletions src/as/materials/MeshDepthMaterial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {Material} from './Material.js'
import {BasicDepthPacking, DepthPackingStrategies} from '../constants.js'
import {Texture} from '../textures/Texture.js'

/**
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
* @author bhouston / https://clara.io
* @author WestLangley / http://github.com/WestLangley
*
* parameters = {
*
* opacity: <float>,
*
* map: new THREE.Texture( <Image> ),
*
* alphaMap: new THREE.Texture( <Image> ),
*
* displacementMap: new THREE.Texture( <Image> ),
* displacementScale: <float>,
* displacementBias: <float>,
*
* wireframe: <boolean>,
* wireframeLinewidth: <float>
* }
*/

// export interface MeshDepthMaterialParameters extends MaterialParameters {
// depthPacking?: DepthPackingStrategies
// displacementMap?: Texture
// displacementScale?: f32
// displacementBias?: f32
// wireframe?: boolean
// wireframeLinewidth?: f32
// }

export class MeshDepthMaterial extends Material {
isMeshDepthMaterial = true

depthPacking: DepthPackingStrategies = BasicDepthPacking

skinning: Boolean = false
morphTargets: Boolean = false

map: Texture | null = null

alphaMap: Texture | null = null

displacementMap: Texture | null = null
displacementScale: f32 = 1
displacementBias: f32 = 0

wireframe: boolean = false
wireframeLinewidth: f32 = 1

fog: boolean = false
lights: boolean = false

constructor(/*parameters: MeshDepthMaterialParameters*/) {
super()
this.type = 'MeshDepthMaterial'
}

/**
* Copy the properties from the passed material into this material.
*/
copy(source: MeshDepthMaterial): this {
Material.prototype.copy.call(this, source)

this.depthPacking = source.depthPacking

this.skinning = source.skinning
this.morphTargets = source.morphTargets

this.map = source.map

this.alphaMap = source.alphaMap

this.displacementMap = source.displacementMap
this.displacementScale = source.displacementScale
this.displacementBias = source.displacementBias

this.wireframe = source.wireframe
this.wireframeLinewidth = source.wireframeLinewidth

return this
}
}

0 comments on commit 0060e3d

Please sign in to comment.