mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
parent
0972dfa457
commit
15d6e0c543
@ -5,6 +5,7 @@ __all__ = ['Actor']
|
|||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
from panda3d.core import Loader as PandaLoader
|
from panda3d.core import Loader as PandaLoader
|
||||||
from direct.showbase.DirectObject import DirectObject
|
from direct.showbase.DirectObject import DirectObject
|
||||||
|
from direct.showbase.Loader import Loader
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
|
|
||||||
|
|
||||||
@ -1886,6 +1887,9 @@ class Actor(DirectObject, NodePath):
|
|||||||
else:
|
else:
|
||||||
loaderOptions.setFlags(loaderOptions.getFlags() | LoaderOptions.LFReportErrors)
|
loaderOptions.setFlags(loaderOptions.getFlags() | LoaderOptions.LFReportErrors)
|
||||||
|
|
||||||
|
# Ensure that custom Python loader hooks are initialized.
|
||||||
|
Loader._loadPythonFileTypes()
|
||||||
|
|
||||||
# Pass loaderOptions to specify that we want to
|
# Pass loaderOptions to specify that we want to
|
||||||
# get the skeleton model. This only matters to model
|
# get the skeleton model. This only matters to model
|
||||||
# files (like .mb) for which we can choose to extract
|
# files (like .mb) for which we can choose to extract
|
||||||
|
@ -22,6 +22,8 @@ class Loader(DirectObject):
|
|||||||
notify = directNotify.newCategory("Loader")
|
notify = directNotify.newCategory("Loader")
|
||||||
loaderIndex = 0
|
loaderIndex = 0
|
||||||
|
|
||||||
|
_loadedPythonFileTypes = False
|
||||||
|
|
||||||
class Callback:
|
class Callback:
|
||||||
"""Returned by loadModel when used asynchronously. This class is
|
"""Returned by loadModel when used asynchronously. This class is
|
||||||
modelled after Future, and can be awaited."""
|
modelled after Future, and can be awaited."""
|
||||||
@ -149,8 +151,7 @@ class Loader(DirectObject):
|
|||||||
Loader.loaderIndex += 1
|
Loader.loaderIndex += 1
|
||||||
self.accept(self.hook, self.__gotAsyncObject)
|
self.accept(self.hook, self.__gotAsyncObject)
|
||||||
|
|
||||||
if ConfigVariableBool('loader-support-entry-points', True):
|
self._loadPythonFileTypes()
|
||||||
self._loadPythonFileTypes()
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.ignore(self.hook)
|
self.ignore(self.hook)
|
||||||
@ -158,7 +159,14 @@ class Loader(DirectObject):
|
|||||||
del self.base
|
del self.base
|
||||||
del self.loader
|
del self.loader
|
||||||
|
|
||||||
def _loadPythonFileTypes(self):
|
@classmethod
|
||||||
|
def _loadPythonFileTypes(cls):
|
||||||
|
if cls._loadedPythonFileTypes:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not ConfigVariableBool('loader-support-entry-points', True):
|
||||||
|
return
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
try:
|
try:
|
||||||
pkg_resources = importlib.import_module('pkg_resources')
|
pkg_resources = importlib.import_module('pkg_resources')
|
||||||
@ -171,6 +179,8 @@ class Loader(DirectObject):
|
|||||||
for entry_point in pkg_resources.iter_entry_points('panda3d.loaders'):
|
for entry_point in pkg_resources.iter_entry_points('panda3d.loaders'):
|
||||||
registry.register_deferred_type(entry_point)
|
registry.register_deferred_type(entry_point)
|
||||||
|
|
||||||
|
cls._loadedPythonFileTypes = True
|
||||||
|
|
||||||
# model loading funcs
|
# model loading funcs
|
||||||
def loadModel(self, modelPath, loaderOptions = None, noCache = None,
|
def loadModel(self, modelPath, loaderOptions = None, noCache = None,
|
||||||
allowInstance = False, okMissing = None,
|
allowInstance = False, okMissing = None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user