Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
aa824ac0
Commit
aa824ac0
authored
6 years ago
by
tony056
Browse files
Options
Downloads
Patches
Plain Diff
moved tunnel-effect to 'systems' folder.
parent
ea6f19e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/tunnel-effect.js
+0
-62
0 additions, 62 deletions
src/components/tunnel-effect.js
src/systems/tunnel-effect.js
+136
-0
136 additions, 0 deletions
src/systems/tunnel-effect.js
with
136 additions
and
62 deletions
src/components/tunnel-effect.js
deleted
100644 → 0
+
0
−
62
View file @
ea6f19e7
import
"
./shaderlib/EffectComposer
"
;
import
"
./shaderlib/RenderPass
"
;
import
"
./shaderlib/ShaderPass
"
;
import
"
./shaderlib/MaskPass
"
;
import
"
./shaderlib/CopyShader
"
;
import
"
./shaderlib/VignetteShader
"
;
AFRAME
.
registerComponent
(
'
tunneleffect
'
,
{
schema
:
{
checkThresholdMs
:
{
type
:
'
number
'
,
default
:
200
},
},
init
:
function
()
{
this
.
scene
=
this
.
el
.
sceneEl
;
this
.
image
=
document
.
querySelector
(
'
#tunnel-effect
'
);
this
.
isMoving
=
0
;
this
.
image
.
setAttribute
(
'
visible
'
,
false
);
const
openTunnelEffect
=
this
.
_openTunnelEffect
.
bind
(
this
);
this
.
scene
.
addEventListener
(
'
move
'
,
openTunnelEffect
);
this
.
dt
=
0
;
this
.
t
=
0
;
this
.
threshold
=
300
;
},
_openTunnelEffect
:
function
()
{
if
(
!
this
.
isMoving
)
{
this
.
image
.
setAttribute
(
'
visible
'
,
true
);
this
.
isMoving
=
true
;
}
this
.
t
=
this
.
scene
.
time
;
},
_closeTunnelEffect
:
function
()
{
console
.
log
(
'
visible false
'
);
},
tick
:
function
(
time
,
deltaTime
)
{
if
(
this
.
isMoving
&&
time
-
this
.
t
>
this
.
threshold
)
{
this
.
isMoving
=
false
;
this
.
image
.
setAttribute
(
'
visible
'
,
false
);
this
.
t
=
time
;
}
},
play
:
function
()
{
// this._closeTunnelEffect();
}
});
// AFRAME.registerComponent('post-effect', {
// init: function () {
// },
// tick: function () {
// console.log('component ticks');
// this.system.renderPass();
// }
// });
This diff is collapsed.
Click to expand it.
src/systems/tunnel-effect.js
0 → 100644
+
136
−
0
View file @
aa824ac0
import
"
./shaderlib/EffectComposer
"
;
import
"
./shaderlib/RenderPass
"
;
import
"
./shaderlib/ShaderPass
"
;
import
"
./shaderlib/MaskPass
"
;
import
"
./shaderlib/CopyShader
"
;
import
"
./shaderlib/VignetteShader
"
;
AFRAME
.
registerSystem
(
'
tunneleffect
'
,
{
schema
:
{
checkThresholdMs
:
{
type
:
'
number
'
,
default
:
500
},
vignetteFadingMs
:
{
type
:
'
number
'
,
default
:
1200
},
movingEvent
:
{
type
:
'
string
'
,
default
:
'
move
'
},
radius
:
{
type
:
'
number
'
,
default
:
0.9
,
min
:
0.5
},
softness
:
{
type
:
'
number
'
,
default
:
0.1
,
min
:
0.0
},
opacity
:
{
type
:
'
number
'
,
default
:
0.9
,
min
:
0.0
}
},
init
:
function
()
{
console
.
log
(
'
init tunneleffect
'
);
const
data
=
this
.
data
;
this
.
scene
=
this
.
el
;
this
.
isMoving
=
false
;
this
.
dt
=
0
;
this
.
t
=
0
;
this
.
thresholdMs
=
data
.
checkThresholdMs
;
this
.
fadingMs
=
data
.
vignetteFadingMs
;
this
.
initMs
=
Date
.
now
();
this
.
radius
=
data
.
radius
;
this
.
minRadius
=
0.5
;
this
.
softness
=
data
.
softness
;
this
.
opacity
=
data
.
opacity
;
this
.
movingStartTimeMs
=
0
;
this
.
lastMovingTimeMs
=
0
;
// original render function of the renderer
this
.
originalRenderFunc
=
this
.
scene
.
renderer
.
render
;
// add event listener for moving event
this
.
enableTunnelEffect
=
this
.
enableTunnelEffect
.
bind
(
this
);
this
.
scene
.
addEventListener
(
data
.
movingEvent
,
this
.
enableTunnelEffect
);
},
update
:
function
()
{
// todo
},
play
:
function
()
{
},
pause
:
function
()
{
this
.
scene
.
removeEventListener
(
data
.
movingEvent
,
this
.
enableTunnelEffect
);
},
tick
:
function
(
time
,
deltaTime
)
{
if
(
this
.
isMoving
)
{
if
(
time
-
this
.
movingStartTimeMs
<
this
.
fadingMs
)
{
console
.
log
(
'
fading
'
);
const
progress
=
(
time
-
this
.
movingStartTimeMs
)
/
this
.
fadingMs
;
const
r
=
this
.
radius
-
(
this
.
radius
-
this
.
minRadius
)
*
progress
;
this
.
_updateVignettePass
(
r
,
this
.
softness
,
this
.
opacity
);
}
else
{
if
(
time
-
this
.
lastMovingTimeMs
>
this
.
thresholdMs
)
{
console
.
log
(
'
idle
'
);
this
.
isMoving
=
false
;
this
.
scene
.
renderer
.
render
=
this
.
originalRenderFunc
;
this
.
lastMovingTimeMs
=
time
;
this
.
movingStartTimeMs
=
time
;
}
}
}
else
{
if
(
this
.
scene
.
renderer
.
render
!==
this
.
originalRenderFunc
)
{
this
.
scene
.
renderer
.
render
=
this
.
originalRenderFunc
;
}
}
},
_updateComposer
:
function
()
{
if
(
!
this
.
renderer
)
{
this
.
renderer
=
this
.
scene
.
renderer
;
this
.
camera
=
this
.
scene
.
camera
;
}
if
(
!
this
.
composer
)
{
this
.
composer
=
new
THREE
.
EffectComposer
(
this
.
renderer
);
}
if
(
!
this
.
scenePass
)
{
this
.
scenePass
=
new
THREE
.
RenderPass
(
this
.
scene
.
object3D
,
this
.
camera
);
}
if
(
!
this
.
vignettePass
)
{
this
.
_updateVignettePass
(
this
.
radius
,
this
.
softness
,
this
.
opacity
);
}
this
.
composer
.
addPass
(
this
.
scenePass
);
this
.
composer
.
addPass
(
this
.
vignettePass
);
},
_updateVignettePass
:
function
(
radius
,
softness
,
opacity
)
{
if
(
!
this
.
vignettePass
)
{
this
.
vignettePass
=
new
THREE
.
ShaderPass
(
THREE
.
VignetteShader
);
}
const
{
width
,
height
}
=
this
.
renderer
.
getSize
();
const
pixelRatio
=
this
.
renderer
.
getPixelRatio
();
this
.
vignettePass
.
uniforms
[
'
radius
'
].
value
=
radius
;
this
.
vignettePass
.
uniforms
[
'
softness
'
].
value
=
softness
;
this
.
vignettePass
.
uniforms
[
'
opacity
'
].
value
=
opacity
;
this
.
vignettePass
[
'
resolution
'
]
=
new
THREE
.
Uniform
(
new
THREE
.
Vector2
(
width
*
pixelRatio
,
height
*
pixelRatio
));
if
(
!
this
.
vignettePass
.
renderToScreen
)
{
this
.
vignettePass
.
renderToScreen
=
true
;
}
},
bindRenderFunc
:
function
()
{
const
renderer
=
this
.
scene
.
renderer
;
const
render
=
renderer
.
render
;
const
system
=
this
;
let
isDigest
=
false
;
renderer
.
render
=
function
()
{
if
(
isDigest
)
{
render
.
apply
(
this
,
arguments
);
}
else
{
isDigest
=
true
;
system
.
composer
.
render
(
system
.
dt
);
isDigest
=
false
;
}
};
},
enableTunnelEffect
:
function
()
{
if
(
this
.
isMoving
)
{
this
.
lastMovingTimeMs
=
Date
.
now
()
-
this
.
initMs
;
return
;
}
this
.
isMoving
=
true
;
this
.
movingStartTimeMs
=
Date
.
now
()
-
this
.
initMs
;
this
.
_updateComposer
();
this
.
bindRenderFunc
();
}
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment