Skip to content

Commit

Permalink
transitioned imports for THREE in sdf's
Browse files Browse the repository at this point in the history
  • Loading branch information
atlmtw committed Jul 25, 2022
1 parent 5e4e436 commit b2618de
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "three-bmfont-text",
"name": "three-bmfont-text-es",
"version": "3.0.0",
"description": "renders BMFont files in ThreeJS with word-wrapping",
"description": "ES6 Module that enables BMFont files in ThreeJS with word-wrapping. Originally created by Matt DesLauriers (https://github.com/mattdesl/)",
"license": "MIT",
"author": {
"name": "Matt DesLauriers",
"email": "[email protected]",
"url": "https://github.com/mattdesl"
"name": "Mason Wong",
"url": "https://github.com/atlmtw"
},
"peerDependencies": {
"three": ">=0.120.0"
Expand Down
6 changes: 4 additions & 2 deletions src/shaders/basic.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Texture, Color } from 'three';

export function createBasicShader (opt) {
opt = opt || {}
var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1
Expand All @@ -15,8 +17,8 @@ export function createBasicShader (opt) {
return Object.assign({
uniforms: {
opacity: { type: 'f', value: opacity },
map: { type: 't', value: map || new THREE.Texture() },
color: { type: 'c', value: new THREE.Color(color) }
map: { type: 't', value: map || new Texture() },
color: { type: 'c', value: new Color(color) }
},
vertexShader: [
'attribute vec2 uv;',
Expand Down
6 changes: 4 additions & 2 deletions src/shaders/msdf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Texture, Color } from 'three';

export function createMSDFShader (opt) {
opt = opt || {};
var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1;
Expand All @@ -17,8 +19,8 @@ export function createMSDFShader (opt) {
return Object.assign({
uniforms: {
opacity: { type: 'f', value: opacity },
map: { type: 't', value: map || new THREE.Texture() },
color: { type: 'c', value: new THREE.Color(color) }
map: { type: 't', value: map || new Texture() },
color: { type: 'c', value: new Color(color) }
},
vertexShader: [
'attribute vec2 uv;',
Expand Down
6 changes: 4 additions & 2 deletions src/shaders/multipage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { REVISION, Color } from 'three';

export function createMultipageShader (opt) {
opt = opt || {}
var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1
Expand Down Expand Up @@ -40,15 +42,15 @@ export function createMultipageShader (opt) {
attributes: { page: { type: 'f', value: 0 } }
}

var threeVers = (parseInt(THREE.REVISION, 10) || 0) | 0
var threeVers = (parseInt(REVISION, 10) || 0) | 0
if (threeVers >= 72) {
attributes = undefined
}

return Object.assign({
uniforms: Object.assign({}, baseUniforms, {
opacity: { type: 'f', value: opacity },
color: { type: 'c', value: new THREE.Color(color) }
color: { type: 'c', value: new Color(color) }
}),
vertexShader: [
'attribute vec4 position;',
Expand Down
6 changes: 4 additions & 2 deletions src/shaders/sdf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Texture, Color } from 'three';

export function createSDFShader (opt) {
opt = opt || {}
var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1
Expand All @@ -15,8 +17,8 @@ export function createSDFShader (opt) {
return Object.assign({
uniforms: {
opacity: { type: 'f', value: opacity },
map: { type: 't', value: map || new THREE.Texture() },
color: { type: 'c', value: new THREE.Color(color) }
map: { type: 't', value: map || new Texture() },
color: { type: 'c', value: new Color(color) }
},
vertexShader: [
'attribute vec2 uv;',
Expand Down

0 comments on commit b2618de

Please sign in to comment.